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.
This function serves a copy of the requested image. This copy is generated using all the options set like interlacing, jpeg quality, sharpening...
location ~* \.(jpg|jpeg) {
image_filter_interlace on;
image_filter_jpeg_quality 75;
image_filter 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.
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;
}