You are here

How to resize images with SLIR

How to resize images with SLIR - winter on the lake example

It is essential to have a great image resizer tool for your project. Most of CMS platforms offer built in features or community contributed extensions, but how about something universal a platformless tool. Fortunately SLIR comes for help.

Lets move on  and check it out and see how we can easily use it.


Normaly I would write this in one sentence - follow the guidelines in README file. There are though some trips and tricks which the default guidelines do not say a word about (Code examples are designed for Linux Ubuntu, so amend accorging to your system needs).

  • We will not put this under main web root otherwise it will mess up CMS url structures, lets use server alias, like; 
Alias /slir "/path/to/slir"
  • To avoid installation errors few more things you need to do;
    1. Copy the configuration file - "cp slirconfig-sample.class.php slirconfig.class.php"
    2. Make the log file to be writable by a web server - "sudo chown www-data:www-data slir-error-log"
    3.  Create a cache folder and make ir writable for a web server "mkdir cache && chown -R www-data:www-data cache"
  • Once done with all this point your browser to . This will validate your installation.


Ok we've installed it lets see what great usage ir porvides. In an essence it is simple - developer just have to create an image tag like this;

<img src="/slir/w100/path/to/image.jpg"/>

what it means - slir/{resize_pattern}/path/to/image . Good thing to mention here - path to image is relative to web root hence you don't have look and configure this somewhere else on your system. Resize patterns are awailable to big extent covering most of the needs;

  • w - max width
  • h - max height
  • c - crop ratio
  • q - Quality
  • b - background fill color
  • p - progressive


SLIR is a great and fantastic tool, but you might need some time to amend and use it for your projects. Front end developers will probably embrace it,  backenders could start pulling their hair off!! Here are the main overview if gains and losses you will get.

Good parts;

  1. Obvious and easy to use,
  2. Convenience,
  3. Platform independent,
  4. Caching, 
  5. No replication of resized images,.

Bad parts;

  1. Another extra tool to run,
  2. No support for remote images,
  3. Documentation to maitain - regarding image paths,
  4. May not meet all your needs (extra image manipulation effects).

Hope you enjoyed it - happy imaging.