Skip to content

Patched Nginx Image Filter module to allow interlace even if no rotation/crop/resize is requested.

Notifications You must be signed in to change notification settings

bbaumann/nginx_image_filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

nginx_image_filter

This is basically the Nginx Image Filter module but patched to allow interlace, jpeg quality setting and sharpening even if no rotation/crop/resize is requested.

This module is based upon nginx 1.6.2 image_filter module code.

Image_filter copy

This function serves a copy of the requested image. This copy is generated using all the options set like interlacing, jpeg quality, sharpening...

Example

location ~* \.(jpg|jpeg) {
   image_filter_interlace on;
   image_filter_jpeg_quality 75;

   image_filter copy;
}

Image_filter resize_or_copy

This function is similar to the resize function except that when a resize is not needed (for example when requested width exceeds the image width, or when width and height are not set) a copy of the image is served (whereas the resize method serves the image "as is"). This copy is generated using all the options set like interlacing, jpeg quality, sharpening...

This function was done to cope with the "if is evil" nginx problem. The image_filter functions cannot be used inside an "if" block so the business logic to copy when no resize is requested has to be done inside the module.

Example

set $width "-";
set $quality "75";
set $height "-";

if ($arg_w != '') {
   set $width $arg_w;
}

location ~* \.(jpg|jpeg) {
   image_filter_interlace on;
   image_filter_jpeg_quality $quality;

   image_filter resize_or_copy $width $height;
}

About

Patched Nginx Image Filter module to allow interlace even if no rotation/crop/resize is requested.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages