PHPackages                             sparwelt/imgix-lib - 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. sparwelt/imgix-lib

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

sparwelt/imgix-lib
==================

Generate and transform urls and responsive images.

0.3.6(6y ago)04.7k11MITPHPPHP &gt;=5.6.0CI failing

Since Jul 24Pushed 5y ago2 watchersCompare

[ Source](https://github.com/sparwelt/imgix-lib)[ Packagist](https://packagist.org/packages/sparwelt/imgix-lib)[ Docs](https://github.com/sparwelt/imgix-lib)[ RSS](/packages/sparwelt-imgix-lib/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (29)Used By (1)

[![Build Status](https://camo.githubusercontent.com/14691b491f104fa57923733dd7b3096832d551f6447d061ab53f9a71d8eb3597/68747470733a2f2f7472617669732d63692e6f72672f7370617277656c742f696d6769782d6c69622e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sparwelt/imgix-lib)[![Coverage Status](https://camo.githubusercontent.com/2e7d83f05259019a4cae94dbf6069c15a92ebd2f000d203701dc13e5da5cb53c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7370617277656c742f696d6769782d6c69622f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/sparwelt/imgix-lib?branch=master)

Imgix Library
=============

[](#imgix-library)

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

[](#installation)

```
composer require sparwelt/imgix-lib
```

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
// initialization
$cdnConfiguration = ['my_cdn' => ['my.imgix.net']];
$imgix = ImgixServiceFactory::createFromConfiguration($cdnConfiguration);

// url generation
echo $imgix->generateUrl('/dir/test.png', ['w' => 100, 'h' => 200]);
// "https://my.imgix.net/dir/test.png?w=100&h=200"

// image generation
echo $imgix->generateImage('/dir/test.png', ['src' => ['w' => 100, 'h' => 200]]);
//

// html conversion
echo $imgix->transformHtml('', ['src' => ['w' => 100, 'h' => 200]]);
// ''
```

### Responsive usage

[](#responsive-usage)

```
// image generation
echo $imgix->generateImage('/dir/test.png', [
            'src' => [ 'h' => 150, 'w' => 300],
            'srcset' => [
                '100w' => [ 'h' => 300, 'w' => 600],
                '500w' => [ 'h' => 600, 'w' => 900],
            ],
            'sizes' => '(min-width: 900px) 1000px, (max-width: 900px)'
]);
//

// attribute generation
echo sprintf('', $imgix->generateAttributeValue('test.png', [
    '2x' => ['w' => 400, 'h' => 200]
    '3x' => ['w' => 600, 'h' => 300]
]);
//
```

### Lazyloading

[](#lazyloading)

```
echo $imgix->generateImage('/dir/test.png', [
            'src' => [ 'h' => 30, 'w' => 60],
            'srcset' => 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==',
            'data-srcset' => [
                '100w' => ['h' => 60, 'w' => 120]
                '500w' => ['h' => 90, 'w' => 180],
            ],
            'data-sizes' => 'auto',
            'class' => 'lazyload',
        ],
]);
//
```

### Named filters

[](#named-filters)

Instead of specifying filters at every usage, named filters can be configured once and recalled by name:

```
$imgix = ImgixServiceFactory::createFromConfiguration($cdnConfiguration, [
    'my_basic_filter' => [
        'src' => ['w' => 30, 'h' => 60]
    ],
    'my_blur_lazyload_filter' => [
          'src' => ['h' => 30, 'w' => 60],
          'data-src' => ['h' => 30, 'w' => 60, 'blur' => 1000],
          'data-srcset' => [
              '100w' => ['h' => 60, 'w' => 120]
              '500w' => ['h' => 90, 'w' => 180],
          ],
          'data-sizes' => 'auto',
          'class' => 'lazyload',
    ]
]);

echo $imgix->generateImage('dir/test.png', 'my_basic_filter');
//

echo $imgix->generateImage('dir/test.png', 'my_blur_lazyload_filter');
//

echo $imgix->generateUrl('dir/test.png', 'my_blur_lazyload_filter.src');
//https://test.imgix.net/dir/test.png?h=30&w=60

echo $imgix->generateUrl('dir/test.png', 'my_normal_filter', ['q' => 75]);
//https://test.imgix.net/dir/test.png?h=30&w=60&q=75

echo $imgix->transformHtml($html, 'my_blur_lazyload_filter');
//... replaces all images with responsive ones
```

### Multiple cdn configurations

[](#multiple-cdn-configurations)

The image path will be evaluate against the configurations, starting from the top one, until a suitable match is found. Multiple domains can be specified for the same configuration (domain sharding).

```
$imgix = ImgixServiceFactory::createFromConfiguration([

        // matches images with source domain 'mysite.com' (including subdomains)
        // AND path beginning with 'uploads/' OR 'media/'
        // Relative urls won't match
        'source_domains_and_pattern' => [
            'cdn_domains' => ['my-cdn-1.imgix.net'],
            'source_domains' => ['mysite.com'],
            'path_patterns' => ['^[/]uploads/', '^[/]media/'],
        ],

        // matches images with source domain exactly 'www3.mysite.com' OR 'www4.mysite.com'
        // Relative urls won't match
        'source_sub_domain' => [
            'cdn_domains' => ['my-cdn-2.imgix.net'],
            'source_domains' => ['www3.mysite.com', 'www4.mysite.com'],
        ],

        // matches images with source domain 'mysite.com' (including subdomains)
        // Relative urls won't match
        'source_domains' => [
            'cdn_domains' => ['my-cdn-3.imgix.net'],
            'source_domains' => ['mysite.com'],
        ],

        // matches images with source domain 'mysite.com' (including subdomains)
        // AND relative urls (because of the 'null')
        'source_domains_and_null' => [
            'cdn_domains' => ['my-cdn-4.imgix.net'],
            'source_domains' => ['mysite.com', null],
        ],

        // matches relative urls only, where path begins with 'uploads/'.
        // Absolute urls won't match.
        'pattern' => [
            'cdn_domains' => ['my-cdn-5.imgix.net'],
            'path_patterns' => ['^[/]pattern/'],
        ],

        // matches relative urls only, where path begins with 'sign-key/'.
        // appends sign-key to the generated url (recommended)
        'sign_key' => [
            'cdn_domains' => ['my-cdn-6.imgix.net'],
            'path_patterns' => ['[^]/sign-key/'],
            'sign_key' => '12345',
        ],

        // matches relative urls only, where path begins with 'shard-crc/'.
        // Will choose the cdn domains by the hash of the path (recommended)
        'shard_crc' => [
            'cdn_domains' => ['my-cdn-7.imgix.net', 'my-cdn-8.imgix.net'],
            'path_patterns' => ['^[/]shard-crc/'],
        ],

        // matches relative urls only, where path begins with 'shard-cycle/'.
        // Will rotate between the 2 cdn domains (increase costs)
        'shard_cycle' => [
            'cdn_domains' => ['my-cdn-9.imgix.net', 'my-cdn-10.imgix.net'],
            'path_patterns' => ['^[/]shard-cycle/'],
            'shard_strategy' => 'cycle',
        ],

        // default parameters can be added, useful for cache bursting or automatic formatting
        'default_parameters' => [
            'cdn_domains' => ['my-cdn-11.imgix.net'],
            'path_patterns' => ['^[/]shard-cycle/'],
            'default_query_params' => ['cb' => '1234', 'auto' => 'quality'],
        ],

        // disable parameters generation
        // (useful for development/testing environments)
        'bypass_dev' => [
            'cdn_domains' => ['my-dev-domain.test'],
            'source_domains' => ['my-dev-domain.test'],
            'generate_filter_params' => false,
            'use_ssl' => false
        ],

        // matches all relative urls
        'default' => [
            'cdn_domains' => ['my-cdn-12.imgix.net'],
        ],
    ]);
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~20 days

Recently: every ~103 days

Total

26

Last Release

2398d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06d2f80d221762b9ad79bdbb54d1d1cc216408fbb012e8b553838f6f4d106481?d=identicon)[federico.infanti](/maintainers/federico.infanti)

---

Top Contributors

[![finfa](https://avatars.githubusercontent.com/u/4535128?v=4)](https://github.com/finfa "finfa (1 commits)")[![martianlife](https://avatars.githubusercontent.com/u/44425873?v=4)](https://github.com/martianlife "martianlife (1 commits)")[![VStoltzenberg](https://avatars.githubusercontent.com/u/1061135?v=4)](https://github.com/VStoltzenberg "VStoltzenberg (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sparwelt-imgix-lib/health.svg)

```
[![Health](https://phpackages.com/badges/sparwelt-imgix-lib/health.svg)](https://phpackages.com/packages/sparwelt-imgix-lib)
```

###  Alternatives

[spacecatninja/imager-x

Ninja powered image transforms.

29399.9k35](/packages/spacecatninja-imager-x)[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[riclep/laravel-storyblok

A Laravel wrapper around the Storyblok API to provide a familiar experience for Laravel devs

6277.0k5](/packages/riclep-laravel-storyblok)[elgentos/magento2-imgix

Imgix extension for Magento 2 to process images

1669.3k](/packages/elgentos-magento2-imgix)[otisz/laravel-imgix

1419.4k](/packages/otisz-laravel-imgix)[rsoury/wp-imgix

Rewrites WordPress image URLs to use ImgIX

167.2k](/packages/rsoury-wp-imgix)

PHPackages © 2026

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