SLIR (Smart Lencioni Image Resizer)
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.
- PHP 5.1.2+
- GD Graphics Library -- must be a version that supports
imageconvolution(), such as the bundled version
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
After you have SLIR downloaded, visit
http://yourdomain.com/slir/install/ in your favorite web browser.
To use SLIR, place an
<img\> 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.
<img src="/slir/w100/path/to/image.jpg"/>). All parameters follow the pattern of a one-letter code and then the parameter value:
|b||Background fill color||
Separate multiple parameters with a hyphen:
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 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)
Matting a PNG with #990000
Without mod_rewrite (not recommended)
Special characters (e.g.
+) 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
If you would like to support SLIR or to show your appreciation for the time spend developing this project, please make a financial contribution.
For more documentation, open
core/slir.class.php in your favorite text editor.