PHPackages                             greg-md/php-static-image - 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. greg-md/php-static-image

Abandoned → [greg-md/php-imagix](/?search=greg-md%2Fphp-imagix)Library[Image &amp; Media](/categories/media)

greg-md/php-static-image
========================

Save images in real-time in different formats using Intervention Image.

0149[1 PRs](https://github.com/greg-md/php-imagix/pulls)PHP

Since Jul 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/greg-md/php-imagix)[ Packagist](https://packagist.org/packages/greg-md/php-static-image)[ RSS](/packages/greg-md-php-static-image/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Greg PHP Imagix
===============

[](#greg-php-imagix)

[![StyleCI](https://camo.githubusercontent.com/b6d4eb8d5e3c6d8d25ed5d12be990ee5f3a465b50bb981fb2c72623877148509/68747470733a2f2f7374796c6563692e696f2f7265706f732f37303833353538302f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/70835580)[![Build Status](https://camo.githubusercontent.com/16021c152bcc0f21bec9ee6c202cfd6dd7bf19d0b0f9f59ba9cbef52b129041b/68747470733a2f2f7472617669732d63692e6f72672f677265672d6d642f7068702d696d616769782e737667)](https://travis-ci.org/greg-md/php-imagix)[![Total Downloads](https://camo.githubusercontent.com/a631a321174207fc659a7475cc4c9985609a116eb0bd8a96eff6b4b303c732ef/68747470733a2f2f706f7365722e707567782e6f72672f677265672d6d642f7068702d696d616769782f642f746f74616c2e737667)](https://packagist.org/packages/greg-md/php-imagix)[![Latest Stable Version](https://camo.githubusercontent.com/ce0edb24b84d8ef43b85839657428a35f98013f572932f74ebdf586c655e8622/68747470733a2f2f706f7365722e707567782e6f72672f677265672d6d642f7068702d696d616769782f762f737461626c652e737667)](https://packagist.org/packages/greg-md/php-imagix)[![Latest Unstable Version](https://camo.githubusercontent.com/4b5688e17971a2a7b9ccc9b3518254a4e5b498dcc4b694b36c26b85551144eec/68747470733a2f2f706f7365722e707567782e6f72672f677265672d6d642f7068702d696d616769782f762f756e737461626c652e737667)](https://packagist.org/packages/greg-md/php-imagix)[![License](https://camo.githubusercontent.com/4e75eeeae44888d04537766fe2f388336655f791b1ca4d9e22d622b0d84268a5/68747470733a2f2f706f7365722e707567782e6f72672f677265672d6d642f7068702d696d616769782f6c6963656e73652e737667)](https://packagist.org/packages/greg-md/php-imagix)

Save images in real-time in different formats using [Intervention Image](http://image.intervention.io/).

You don't care anymore about generating new images from their sources when your app UI was changed. Only thing you should do is to add new formats or change existent and the application will take care of them by itself.

Table of Contents:
==================

[](#table-of-contents)

- [Requirements](#requirements)
- [How It Works](#how-it-works)
- [Methods](#methods)
- [License](#license)
- [Huuuge Quote](#huuuge-quote)

Requirements
============

[](#requirements)

- PHP Version `^5.6 || ^7.0`

How It Works
============

[](#how-it-works)

**First of all**, you have to initialize the Imagix.

Optionally you can create an URL decorator for it. It helps to rewrite image URLs to/from HTTP Server(Apache/Nginx).

```
class ImagixDecorator implements ImageDecoratorStrategy
{
    // Will use /imagix public path for generated images.
    private $uri = '/imagix';

    public function output($url)
    {
        return $this->nginxUri . $url;
    }

    public function input($url)
    {
        return \Greg\Support\Str::shift($url, $this->uri);
    }
}

$sourcePath = __DIR__ . '/img';

$destinationPath = __DIR__ . '/imagix';

$decorator = new ImagixDecorator();

$intervention = new Intervention\Image\ImageManager();

$imagix = new \Greg\Imagix\Imagix($intervention, $sourcePath, $destinationPath, $decorator);
```

**Next**, create image formats.

```
$imagix->format('square', function (\Intervention\Image\Image $image) {
    $image->resize(600, 600, function (\Intervention\Image\Constraint $constraint) {
        $constraint->aspectRatio();
        $constraint->upsize();
    });
});
```

**Now**, it's time to use it in your app.

It will generate an URL in format `/@@.`.

```
// result: /imagix/pictures/picture@square@129648839.jpg
$imageUrl = $imagix->url('/pictures/picture.jpg', 'square');

echo '';
```

To see the results, you have to config your `http server`.

**Nginx**

```
# Imagix
location ~* ^/imagix/.+ {
    # If images doesn't exists, send to PHP to create it.
    if (!-f $document_root$uri) {
        rewrite .+ /imagix.php last;
    }

    expires max;
    add_header Pragma public;
    add_header Cache-Control "public";
    add_header Vary "Accept-Encoding";
}

```

In **imagix.php** you will dispatch new files that was not generated yet in `/imagix` path.

```
$imagix->send($_SERVER['REQUEST_URI']);
```

Methods
=======

[](#methods)

**Magic methods**:

- [\_\_construct](#__construct)

\_\_construct
-------------

[](#__construct)

Initialize the manager.

```
__construct(ImageManager $manager, string $sourcePath, string $destinationPath, ImageDecoratorStrategy $decorator = null)
```

`$manager` - Intervention image manager;
`$sourcePath` - Source path;
`$destinationPath` - Destination path;
`$decorator` - Decorator.

*Example:*

```
class ImagixDecorator implements ImageDecoratorStrategy
{
    // Will use /imagix public path for generated images.
    private $uri = '/imagix';

    public function output($url)
    {
        return $this->nginxUri . $url;
    }

    public function input($url)
    {
        return \Greg\Support\Str::shift($url, $this->uri);
    }
}

$sourcePath = __DIR__ . '/img';

$destinationPath = __DIR__ . '/imagix';

$decorator = new ImagixDecorator();

$intervention = new Intervention\Image\ImageManager();

$imagix = new \Greg\Imagix\ImagixManager($intervention, $sourcePath, $destinationPath, $decorator);
```

**Supported methods**:

- [format](#format) - Register an image format;
- [url](#url) - Get formatted image URL;
- [source](#source) - Get source URL of a formatted image URL;
- [effective](#effective) - Get effective URL of a formatted image URL;
- [compile](#compile) - Compile a formatted image URL;
- [send](#send) - Send image of a formatted image URL;
- [unlink](#unlink) - Remove formatted versions of an image;
- [remove](#remove) - Remove formatted images.

format
------

[](#format)

Register an image format.

```
format(string $name, callable(\Intervention\Image\Image $image): void $callable): $this
```

`$name` - Format name;
`$callable` - A callable to format an image.
 `$image` - The image.

*Example:*

```
$imagix->format('square', function (\Intervention\Image\Image $image) {
    $image->resize(600, 600, function (\Intervention\Image\Constraint $constraint) {
        $constraint->aspectRatio();
        $constraint->upsize();
    });
});
```

url
---

[](#url)

Get formatted image URL.

```
url(string $source, string $format): string
```

`$source` - Original image URL;
`$format` - Format name.

*Example:*

```
$imagix->url('/pictures/picture.jpg', 'square'); // result: /pictures/picture@square@129648839.jpg
```

source
------

[](#source)

Get source URL of a formatted image URL.

```
source(string $destination): string
```

`$destination` - Formatted image URL.

*Example:*

```
$imagix->source('/pictures/picture@square@129648839.jpg'); // result: /pictures/picture.jpg
```

effective
---------

[](#effective)

Get effective URL of a formatted image URL.

Every time a image changes, it's effective URL also changes. So, if you have an old URL, you will get the new one.

> This is useful when you store somewhere formatted urls.

> By default, [`send`](#send) method will return a 301 redirect to the new URL.

```
effective(string $destination): string
```

`$destination` - Formatted image URL.

*Example:*

```
$imagix->effective('/pictures/picture@square@129642346.jpg'); // result: /pictures/picture@square@129648839.jpg
```

compile
-------

[](#compile)

Compile a formatted image URL. Will return the real path of the image.

```
compile(string $destination): string
```

`$destination` - Formatted image URL.

*Example:*

```
$imagix->compile('/pictures/picture@square@129648839.jpg'); // result: /path/to/pictures/picture@square@129648839.jpg
```

send
----

[](#send)

Send image of a formatted image URL.

```
send(string $destination): $this
```

`$destination` - Formatted image URL.

*Example:*

```
$imagix->send('/pictures/picture@square@129648839.jpg');
```

unlink
------

[](#unlink)

Remove formatted versions of an image.

```
unlink(string $source, string $format = null, int $lifetime = 0): $this
```

`$source` - Formatted image URL;
`$format` - Format name;
`$lifetime` - If set, will remove only expired files.

*Example:*

```
$imagix->unlink('/pictures/picture.jpg');
```

remove
------

[](#remove)

Remove formatted images.

```
remove(string $format = null, int $lifetime = 0): $this
```

`$format` - Format name;
`$lifetime` - If set, will remove only expired files.

*Example:*

```
$imagix->remove(); // Will remove all formatted images.

$imagix->remove('square'); // Will remove only square images.
```

License
=======

[](#license)

MIT © [Grigorii Duca](http://greg.md)

Huuuge Quote
============

[](#huuuge-quote)

[![I fear not the man who has practiced 10,000 programming languages once, but I fear the man who has practiced one programming language 10,000 times. #horrorsquad](https://camo.githubusercontent.com/73fc580403a8367b075fff0a0d7439dc0dc095dd3124b22757522675c1308df8/687474703a2f2f677265672e6d642f6875757567652d71756f74652d66622e6a7067)](https://camo.githubusercontent.com/73fc580403a8367b075fff0a0d7439dc0dc095dd3124b22757522675c1308df8/687474703a2f2f677265672e6d642f6875757567652d71756f74652d66622e6a7067)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/85a6700372326d0546fcff3eb2c3f27daa711273bdd5d6fdda875a7d2f02af85?d=identicon)[greg-md](/maintainers/greg-md)

---

Top Contributors

[![greg-md](https://avatars.githubusercontent.com/u/10551984?v=4)](https://github.com/greg-md "greg-md (3 commits)")

---

Tags

greg-mdgreg-phpimageinterventionintervention-imagephpphp-static-imagestatic-imageweb-artisans

### Embed Badge

![Health badge](/badges/greg-md-php-static-image/health.svg)

```
[![Health](https://phpackages.com/badges/greg-md-php-static-image/health.svg)](https://phpackages.com/packages/greg-md-php-static-image)
```

###  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.0k23](/packages/bkwld-croppa)[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)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)

PHPackages © 2026

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