PHPackages                             mwarcz/segami - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. mwarcz/segami

ActiveLibrary[Image &amp; Media](/categories/media)

mwarcz/segami
=============

PHP library that allows you to edit image dimensions, convert image format, cache generated images, record last access to generated image in cache, remove images from cache that have not been used for long time, all based on image name.

v2.1.0(1y ago)023MITPHPPHP ^8.1

Since Oct 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MWarCZ/segami-php)[ Packagist](https://packagist.org/packages/mwarcz/segami)[ RSS](/packages/mwarcz-segami/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (9)Used By (0)

Segami
======

[](#segami)

Segami is simple PHP library that allows edit image dimensions, convert image format, cache generated images, record last access to generated image in cache, remove images from cache that have not been used for long time, all based on image suffix in name.

[![PHP version](https://camo.githubusercontent.com/a22d675b00f0117667d5f833591af44688e8c4dd48cecc8fb24832ff3a013649/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6d776172637a2f736567616d692f7068703f6c6f676f3d706870266c6f676f436f6c6f723d666666666666266c6162656c3d70687026636f6c6f723d383839324246)](https://www.php.net/supported-versions.php)[![Packagist version](https://camo.githubusercontent.com/3075cb1c4bd0a931352e37f2e4220544305464e28251ab2f811941f024fd11c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d776172637a2f736567616d693f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d666666666666)](https://packagist.org/packages/mwarcz/segami)[![MIT License](https://camo.githubusercontent.com/60ba011c1a09e4f262a0dd522bcc96ee65520d88967d5aa865463ddbc2f88d58/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d576172435a2f736567616d692d706870)](LICENSE)

Key features
------------

[](#key-features)

- **Convert image format**
    - Basic function of library is to convert image into various raster formats (PNG, GIF, JPEG, WebP, etc.).
    - Example: `sample.png@.jpg`, `sample.png@.webp`
- **Create image crop**
    - Optional function allows you to crop image in required dimensions.
    - Example: `sample.png@c200x100.png`, `sample.png@c300.jpg`
- **Resize image**
    - Optional function that allows you to change size of image in the required dimensions and fill type (fill, contain, cover).
    - Example: `sample.png@r200x100_cover.png`, `sample.png@r300.jpg`
- **Set image quality/compression**
    - Optional feature to set image quality/compression, which affects resulting file size and compression for selected format.
    - Example: `sample.png@q80.jpg`, `sample.png@q50.webp`
- **Store generated images (cache)**
    - Library allows storing generated images in cache directory for quick retrieval of generated image, as name of image precisely defines its properties.
    - Image filenames are normalized in background to avoid unnecessary duplication.
        - ex. 1: `sample.png@c200.png` = `sample.png@c200x200.png`
        - ex. 2: `sample.png@r100x100_cover.png` = `sample.png@r100_r.png`
- **Automatic removal of long-term unused images from cache**
    - Library provides functions for removing previously stored images to help clear disk space of images that have not been used for long time.
- **Limiters limiting names of required images**
    - Optionally, it is possible to restrict image names that modify original image.
    - It is recommended to limit image names when storing to cache is enabled, so that potential attacker has difficult time attacking you.

Requirements
------------

[](#requirements)

- PHP 8.1+
    - Mandatory optional:
        - [ext-gd](https://www.php.net/manual/en/book.image)
        - [ext-imagick](https://www.php.net/manual/en/book.imagick.php) s instalovaným [ImageMagick](https://imagemagick.org/)

Installation
------------

[](#installation)

Segami library is available on [Packagist](https://packagist.org/packages/mwarcz/segami) and installing via [Composer](https://getcomposer.org/) is recommended way to install it.

Just use the command in terminal:

```
composer require mwarcz/segami
```

Or manually add to `composer.json` file:

```
{
    "require": {
        "php": "^8.1",
        "mwarcz/segami": "dev-master"
    }
}
```

> **Note:** Replace `dev-master` with [specific version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints). See [Packagist](https://packagist.org/packages/mwarcz/segami) for available versions.

Usage
-----

[](#usage)

Short example of possible basic use of library:

```
$segami = new Segami([
  // Selected path to dir with original images
  'path_to_original_images' => __DIR__ . '/original',
  // Selected path to dir with generated images
  'path_to_generated_images' => __DIR__ . '/generated',
  // Selected plugins for generating images
  'plugin' => [
    // CorePlugin is required minimum - enable core name parsing and image format conversion
    'core' => new CorePlugin(),
    // Optional ResizePlugin - enable/add possibility resize image
    'resize' => new ResizePlugin(),
    // Optional QualityPlugin - enable/add possibility quality image
    'quality' => new QualityPlugin(),
  ],
  // Selected limiter with rules for generated images
  'limiter' => new FreeImageLimiter(),
  // Selected image engine
  'image_factory' => new ImageImagickFactory(),
  // Selected logger for logging access to images
  'image_logger' => new ImageLoggerNone(),
]);

try {
  $segami->smartReturnImage($_GET['image'], isset($_GET['cache']));
} catch (\Throwable $e) {
  http_response_code(404);
}
```

Repository contains set of samples of various use case:

- [Example of basic use](examples/basic/)
- [Example of use with LaxImageLimiter](examples/lax/)
- [Test example used in development](examples/dev/)
- TODO

More detailed information about functions and use case of Segami library can be found in *upcoming* [documentation](doc).

- [Creating name for generated images](doc/ImageName.md)
- [Preparation of limiter for limiting generated images](doc/Limiter.md)
- TODO

License
-------

[](#license)

Segami is licensed under [MIT license](LICENSE).

---

TODO roadmap
------------

[](#todo-roadmap)

See [Czech version](README.cs.md).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance46

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~58 days

Total

7

Last Release

573d ago

Major Versions

0.1.1-alpha → 1.0.12023-12-21

1.2.0 → v2.0.02024-06-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8cc39ed86cec348783707bb93af5e11a2767197038d570eb9e2a8594ee5c188?d=identicon)[MWarCZ](/maintainers/MWarCZ)

---

Top Contributors

[![MWarCZ](https://avatars.githubusercontent.com/u/25386463?v=4)](https://github.com/MWarCZ "MWarCZ (146 commits)")

### Embed Badge

![Health badge](/badges/mwarcz-segami/health.svg)

```
[![Health](https://phpackages.com/badges/mwarcz-segami/health.svg)](https://phpackages.com/packages/mwarcz-segami)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k22](/packages/bkwld-croppa)[marc1706/fast-image-size

fast-image-size is a PHP library that does almost everything PHP's getimagesize() does but without the large overhead of downloading the complete file.

959.4M20](/packages/marc1706-fast-image-size)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
