comparison src/http/modules/ngx_http_image_filter_module.c @ 4601:084137d883ec

Image filter: compare aspect ratio more accurately during crop. Previously used fixed-point calculation caused wrong code path selection in some cases, resulting in incorrect image size. See here for report: http://mailman.nginx.org/pipermail/nginx-devel/2012-April/002123.html
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 21 Apr 2012 19:02:21 +0000
parents d620f497c50f
children 55ccb9f75668 f2dcb25987df
comparison
equal deleted inserted replaced
4600:f1a7633b20a4 4601:084137d883ec
815 815
816 } else { /* NGX_HTTP_IMAGE_CROP */ 816 } else { /* NGX_HTTP_IMAGE_CROP */
817 817
818 resize = 0; 818 resize = 0;
819 819
820 if ((ngx_uint_t) (dx * 100 / dy) 820 if ((double) dx / dy < (double) ctx->max_width / ctx->max_height) {
821 < ctx->max_width * 100 / ctx->max_height)
822 {
823 if ((ngx_uint_t) dx > ctx->max_width) { 821 if ((ngx_uint_t) dx > ctx->max_width) {
824 dy = dy * ctx->max_width / dx; 822 dy = dy * ctx->max_width / dx;
825 dy = dy ? dy : 1; 823 dy = dy ? dy : 1;
826 dx = ctx->max_width; 824 dx = ctx->max_width;
827 resize = 1; 825 resize = 1;