Skip to content
Tatsuhiko Kubo edited this page Sep 26, 2013 · 28 revisions

ngx_small_light

ngx_small_light is a dynamic image transformation module for Nginx. And ngx_small_light is written for using as the same way as mod_small_light as possible in Nginx.(mod_small_light is a Apache module)

Install

Install Dependencies

Before install ngx_small_light( and nginx), install following dependencies.

Install ngx_small_light

cd ${ngx_small_light_src_dir}
./setup
cd {$nginx_src_dir}
./configure --with-pcre --add-module=${ngx_small_light_src_dir}
make
sudo make install

If you want to enable the libraries expect ImageMagick in ngx_small_light, add following options when executing setup. (ImageMagick is always enabled)

./setup --with-imlib2           # enable ImageMagick and Imlib2
./setup --with-gd               # enable ImageMagick and GD
./setup --with-imlib2 --with-gd # enable ImageMagick and Imlib2 and GD

Quick Start

Add following configuration to some server context in nginx.conf and start Nginx.

small_light on;
location ~ small_light[^/]*/(.+)$ {
    set $file $1;
    rewrite ^ /$file;
}

If you can get the original image of image.jpeg from following URL,

http://$host:$port/img/image.jpg

you will be able to get the converted image of image.jpeg from following URL.

http://$host:$port/small_light(dw=300,dh=300)/img/image.jpg

Configuration

The configuration guide explains how to describe a configuration to nginx.conf and about configuratve parameters.

Supporting Formats

ngx_small_light supports JPEG, GIF, PNG. But the translation by Imlib2 does not support to writing GIF-image. Because Imlib2 has the function for loading GIF-image but does not have the function for saving.

So of=gif and e=imlib2 are not enable to specify at once.

Clone this wiki locally