[patch] ngx_http_image_filter_module incorrectly calculates size

Maxim Bublis b at codemonkey.ru
Thu Apr 19 17:29:07 UTC 2012


Hi.

There is a bug in ngx_http_image_resize function from
ngx_http_image_filter_module with incorrect calculation of new image
sizes after resizing with crop in case of original image is capable to
resize with preservation of original proportions (i.e. crop is not
required). For example, resizing image with original sizes of 360x203
to 304x171 with crop, will surprisingly give us resized and cropped
image with sizes of 303x171, though resizing the same image without
crop will give us correct image with sizes of 304x171.
Attached image_filter_crop.patch fixes this undesired behavior.

In the same time i've found that algorithm for calculation of new
image sizes in both resize and crop cases could be generalized.
Attached image_filter.patch uses this idea and reduces number of
duplicated source lines (also includes bugfix from
image_filter_crop.patch).

-- 
Maxim Bublis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image_filter_crop.patch
Type: application/octet-stream
Size: 565 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20120419/08ba9e82/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image_filter.patch
Type: application/octet-stream
Size: 2127 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20120419/08ba9e82/attachment-0001.obj>


More information about the nginx-devel mailing list