PHPackages                             rezozero/slir - 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. rezozero/slir

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

rezozero/slir
=============

SLIR (Smart Lencioni Image Resizer) resizes images, intelligently sharpens, crops based on width:height ratios, color fills transparent GIFs and PNGs, and caches variations for optimal performance.

2.1.3(11y ago)187.2k3MITPHPPHP &gt;=5.3.3

Since Jul 9Pushed 11y ago3 watchersCompare

[ Source](https://github.com/rezozero/slir)[ Packagist](https://packagist.org/packages/rezozero/slir)[ Docs](https://github.com/rezozero/SLIR)[ RSS](/packages/rezozero-slir/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

SLIR (Smart Lencioni Image Resizer)
===================================

[](#slir-smart-lencioni-image-resizer)

### Deprecation notice

[](#deprecation-notice)

**SLIR is now deprecated in favor of [ambroisemaupate/intervention-request](https://github.com/ambroisemaupate/intervention-request) library which is based on the strong [image-intervention](http://image.intervention.io/) PHP framework. You should consider migrating to this new library which keeps the same Url guidelines.**

SLIR (Smart Lencioni Image Resizer) resizes images, intelligently sharpens, crops based on width:height ratios, color fills transparent GIFs and PNGs, and caches variations for optimal performance.

For questions or support, please [use the issue tracker](https://github.com/lencioni/SLIR/issues).

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

[](#requirements)

- [Composer](https://getcomposer.org)
- [PHP](http://php.net) 5.3.6+
- [GD Graphics Library](http://php.net/manual/en/book.image.php) -- must be a version that supports `imageconvolution()`, such as the bundled version

Setting up, standalone
----------------------

[](#setting-up-standalone)

- Download and unpack to a directory in your web root. I recommend putting SLIR in `/slir/` for ease of use. For example, if your website is `http://yourdomain.com`, then SLIR would be at `http://yourdomain.com/slir/`.
- Run `composer install` to generate **autoloader** and dependencies.
- Create your own `SLIRConfig.php` class using `slirconfig-sample.class.php` file. If you want to use a namespaced configuration class, you must define `SLIR_CONFIG_CLASSNAME` global constant with its Full-qualified classname. For example : `define('SLIR_CONFIG_CLASSNAME','\MyCompany\Utils\SLIRConfig');`, then SLIR will look for this class to use static configuration.
- After you have SLIR configured, visit `http://yourdomain.com/slir/install/` in your favorite web browser.

Setting up as a library in a symfony-like environment
-----------------------------------------------------

[](#setting-up-as-a-library-in-a-symfony-like-environment)

- Add *SLIR* to your project `composer.json` as a packagist repository.

```
{
    "require": {
        "rezozero/slir": "2.1.*"
    }
}
```

- Run `composer update` to perform vendor changes. Composer will download SLIR to your `vendor/` folder and create a PSR-4 autoloader.
- Create your `SLIRConfig` class

```
namespace MyBundle\Utils;

/**
 * SLIR Config Class
 *
 * @since 2.0
 * @author Joe Lencioni
 * @package SLIR
 */
class SLIRConfig extends \SLIR\SLIRConfigDefaults
{
  public static function init()
  {
    static::$garbageCollectDivisor =               400;
    static::$garbageCollectFileCacheMaxLifetime =  345600;
    static::$browserCacheTTL  =                    604800; // 7*24*60*60
    static::$pathToCacheDir =                      YOUR_PROJECT_ROOT.'/cache';
    static::$pathToErrorLog =                      YOUR_PROJECT_ROOT.'/files/slir-error-log';
    static::$documentRoot =                        YOUR_PROJECT_ROOT.'/files';
    static::$urlToSLIR =                           '/assets'; // Tell SLIR to listen after "/assets" route
    static::$maxMemoryToAllocate =                 64;
    // This must be the last line of this function
    parent::init();
  }
}

SLIRConfig::init();
```

- Create a route handling SLIR

```
#
# routes.yml
#
SLIRProcess:
    path:     /assets/{queryString}/{filename}
    defaults: { _controller: \MyBundle\Controllers\AssetsController::slirAction }
    requirements: { queryString : "[a-zA-Z0-9\-]+", filename : "[a-zA-Z0-9\-_\.\/]+" }
```

- Create your assets controller

```
// In AssetsController.php class
/**
 * Handle images resize with SLIR vendor
 *
 * @param  string $queryString
 * @param  string $filename
 * @return void
 */
public function slirAction($queryString, $filename)
{
  define('SLIR_CONFIG_CLASSNAME','\MyBundle\Utils\SLIRConfig');

  $slir = new \SLIR\SLIR();
  $slir->processRequestFromURL();

  // SLIR handle response by itself
  // Do not return anything
}
```

Using
-----

[](#using)

To use SLIR, place an `` tag with the `src` attribute pointing to the path of SLIR (typically "/slir/") followed by the parameters, followed by the path to the source image to resize (e.g. ``). All parameters follow the pattern of a one-letter code and then the parameter value:

   Parameter Mearning Example     w Maximum width `/slir/w100/path/to/image.jpg`   h Maximum height `/slir/h100/path/to/image.jpg`   c Crop ratio `/slir/c1x1/path/to/image.jpg`   q Quality `/slir/q60/path/to/image.jpg`   b Background fill color `/slir/bf00/path/to/image.png`   p Progressive `/slir/p1/path/to/image.jpg`   g Grayscale `/slir/g1/path/to/image.jpg`  Separate multiple parameters with a hyphen: `/slir/w100-h100-c1x1/path/to/image.jpg`

### Examples

[](#examples)

#### Resizing an image to a max width of 100 pixels and a max height of 100 pixels

[](#resizing-an-image-to-a-max-width-of-100-pixels-and-a-max-height-of-100-pixels)

```

```

#### Resizing and cropping an image into a square

[](#resizing-and-cropping-an-image-into-a-square)

```

```

#### Resizing and cropping an image to exact dimensions

[](#resizing-and-cropping-an-image-to-exact-dimensions)

To do this, you simply need to make the crop ratio match up with the desired width and height. For example, if you want your image to be exactly 150 pixels wide by 100 pixels high, you could do this:

```

```

Or, more concisely:

```

```

However, SLIR will not enlarge images. So, if your source image is smaller than the desired size you will need to use CSS to make it the correct size.

#### Resizing a JPEG without interlacing (for use in Flash)

[](#resizing-a-jpeg-without-interlacing-for-use-in-flash)

```

```

#### Matting a PNG with #990000

[](#matting-a-png-with-990000)

```

```

#### Without mod\_rewrite (not recommended)

[](#without-mod_rewrite-not-recommended)

```

```

#### Changing SLIR request URL

[](#changing-slir-request-url)

```

```

You can change SLIR request URL to handle it with your own rewrite engine. Just define `SLIRConfig::$urlToSLIR` to your relative folder: here `/assets`.

#### Special characters (e.g. `+`) in image filenames

[](#special-characters-eg--in-image-filenames)

Filenames that include special characters must be URL-encoded (e.g. plus sign, `+`, should be encoded as `%2B`) in order for SLIR to recognize them properly. This can be accomplished by passing your filenames through PHP's `rawurlencode()` function.

```

```

Supporting SLIR
---------------

[](#supporting-slir)

If you would like to support SLIR or to show your appreciation for the time spent developing this project, please make a financial contribution.

- [Dwolla](https://www.dwolla.com/hub/lencioni)
- [Flattr](http://flattr.com/thing/178729/Smart-Lencioni-Image-Resizer-SLIR)

---

For more documentation, open `core/SLIR.php` in your favorite text editor.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 91.9% 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 ~68 days

Total

4

Last Release

4162d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/380026?v=4)[Ambroise Maupate](/maintainers/ambroisemaupate)[@ambroisemaupate](https://github.com/ambroisemaupate)

---

Top Contributors

[![lencioni](https://avatars.githubusercontent.com/u/195534?v=4)](https://github.com/lencioni "lencioni (341 commits)")[![ambroisemaupate](https://avatars.githubusercontent.com/u/380026?v=4)](https://github.com/ambroisemaupate "ambroisemaupate (27 commits)")[![lwward](https://avatars.githubusercontent.com/u/1451413?v=4)](https://github.com/lwward "lwward (1 commits)")[![maximeberard](https://avatars.githubusercontent.com/u/1872808?v=4)](https://github.com/maximeberard "maximeberard (1 commits)")[![patrick-mcdougle](https://avatars.githubusercontent.com/u/1392496?v=4)](https://github.com/patrick-mcdougle "patrick-mcdougle (1 commits)")

---

Tags

imageimage processingresizingresampling

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rezozero-slir/health.svg)

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

###  Alternatives

[media-alchemyst/media-alchemyst

An Object Oriented wrapper for easy multimedia conversion, based on Imagine, FFMpeg, SwfTools, Unoconv and other libs

65218.9k1](/packages/media-alchemyst-media-alchemyst)[toinekamps/responsive-pics

Responsive Pics is a Wordpress tool for resizing images on the fly.

832.2k](/packages/toinekamps-responsive-pics)[otisz/laravel-imgix

1419.4k](/packages/otisz-laravel-imgix)[abwebdevelopers/oc-imageresize-plugin

Image resizing made easy for October CMS

141.3k](/packages/abwebdevelopers-oc-imageresize-plugin)

PHPackages © 2026

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