Page Discussion History


Revision as of 19:26, 22 September 2010 by MichaelLustfield (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



Version: 0.7.54+

This module is a filter for transforming JPEG, GIF and PNG images. It is not enabled by default to enable it, provide this option to ./configure when building nginx:


libgd is required to build and run the module. We recommend using the latest version of libgd.

Example Configuration

location /img/ {
    proxy_pass     http://backend;
    image_filter   resize  150 100;
    error_page     415   = /empty;
location = /empty {



Syntax: image_filter (test|size|resize width height|crop width height)

Default: none

Context: location

Specifies the type of transformation to apply to the image, one of the below:

  • test: checking that the response is indeed an image format JPEG, GIF or PNG. Otherwise, an error 415.
  • size: Gives information about the image in JSON format. For example,
{ "img" : { "width": 100, "height": 100, "type": "gif" } }

Or if an error occurs,

  • resize: proportionally reduces the image to a specified size.
  • crop: proportionally reduces the image to a specified size and trims extra edge.


Syntax: image_filter_buffer size

Default: 1M

Context: http, server, location

Sets the maximum size for reading the image.


Syntax: image_filter_jpeg_quality [0...100]

Default: 75

Context: http, server, location

Sets the rate of loss of information when processing the images as JPEG. The maximum recommended value is 95.


Syntax: image_filter_transparency on|off

Default: on

Context: http, server, location

This directive allows you to disable image transparency in GIF and palette-based PNG to improve image resampling quality.

True color PNG alpha-channels are always preserved despite this setting.

Note: Grayscale PNG's are untested, but should be handled as truecolor PNGs.


Original Documentation