---------- Forwarded message ---------- From: An <[email protected]> Date: 2014-10-29 12:49 GMT+04:00 Subject: ngx_http_image_filter_module - resize увеличение изображений To: [email protected]
Очень удобно, если фильтр может увеличивать изображения. Предлагаю внести следующие изменения. an@an-pc:~/Desktop$ cat ngx_http_image_filter_module.diff # HG changeset patch # User Anton Shefer <[email protected]> # Date 1414566573 -14400 # Wed Oct 29 11:09:33 2014 +0400 # Node ID a499f7c603f2322950698da88213aa53fb81ad46 # Parent 87ada3ba1392fadaf4d9193b5d345c248be32f77 Image filter resize - Increase images diff -r 87ada3ba1392 -r a499f7c603f2 src/http/modules/ngx_http_image_filter_module.c --- a/src/http/modules/ngx_http_image_filter_module.c Mon Oct 27 14:25:56 2014 -0700 +++ b/src/http/modules/ngx_http_image_filter_module.c Wed Oct 29 11:09:33 2014 +0400 @@ -546,7 +546,8 @@ && ctx->width <= ctx->max_width && ctx->height <= ctx->max_height && ctx->angle == 0 - && !ctx->force) + && !ctx->force + && conf->filter != NGX_HTTP_IMAGE_RESIZE) { return ngx_http_image_asis(r, ctx); } @@ -773,7 +774,8 @@ if (!ctx->force && ctx->angle == 0 && (ngx_uint_t) sx <= ctx->max_width - && (ngx_uint_t) sy <= ctx->max_height) + && (ngx_uint_t) sy <= ctx->max_height + && conf->filter != NGX_HTTP_IMAGE_RESIZE) { gdImageDestroy(src); return ngx_http_image_asis(r, ctx); @@ -809,15 +811,19 @@ if (conf->filter == NGX_HTTP_IMAGE_RESIZE) { - if ((ngx_uint_t) dx > ctx->max_width) { + + if ((int)ctx->max_width > 0 && (int)ctx->max_height > 0) { dy = dy * ctx->max_width / dx; - dy = dy ? dy : 1; dx = ctx->max_width; - } - - if ((ngx_uint_t) dy > ctx->max_height) { + if (dy > (int)ctx->max_height) { + dx = dx * ctx->max_height / dy; + dy = ctx->max_height; + } + } else if ((int)ctx->max_width > 0) { + dy = dy * ctx->max_width / dx; + dx = ctx->max_width; + } else if ((int)ctx->max_height > 0) { dx = dx * ctx->max_height / dy; - dx = dx ? dx : 1; dy = ctx->max_height; }
# HG changeset patch # User Anton Shefer <[email protected]> # Date 1414566573 -14400 # Wed Oct 29 11:09:33 2014 +0400 # Node ID a499f7c603f2322950698da88213aa53fb81ad46 # Parent 87ada3ba1392fadaf4d9193b5d345c248be32f77 Image filter resize - Increase images diff -r 87ada3ba1392 -r a499f7c603f2 src/http/modules/ngx_http_image_filter_module.c --- a/src/http/modules/ngx_http_image_filter_module.c Mon Oct 27 14:25:56 2014 -0700 +++ b/src/http/modules/ngx_http_image_filter_module.c Wed Oct 29 11:09:33 2014 +0400 @@ -546,7 +546,8 @@ && ctx->width <= ctx->max_width && ctx->height <= ctx->max_height && ctx->angle == 0 - && !ctx->force) + && !ctx->force + && conf->filter != NGX_HTTP_IMAGE_RESIZE) { return ngx_http_image_asis(r, ctx); } @@ -773,7 +774,8 @@ if (!ctx->force && ctx->angle == 0 && (ngx_uint_t) sx <= ctx->max_width - && (ngx_uint_t) sy <= ctx->max_height) + && (ngx_uint_t) sy <= ctx->max_height + && conf->filter != NGX_HTTP_IMAGE_RESIZE) { gdImageDestroy(src); return ngx_http_image_asis(r, ctx); @@ -809,15 +811,19 @@ if (conf->filter == NGX_HTTP_IMAGE_RESIZE) { - if ((ngx_uint_t) dx > ctx->max_width) { + + if ((int)ctx->max_width > 0 && (int)ctx->max_height > 0) { dy = dy * ctx->max_width / dx; - dy = dy ? dy : 1; dx = ctx->max_width; - } - - if ((ngx_uint_t) dy > ctx->max_height) { + if (dy > (int)ctx->max_height) { + dx = dx * ctx->max_height / dy; + dy = ctx->max_height; + } + } else if ((int)ctx->max_width > 0) { + dy = dy * ctx->max_width / dx; + dx = ctx->max_width; + } else if ((int)ctx->max_height > 0) { dx = dx * ctx->max_height / dy; - dx = dx ? dx : 1; dy = ctx->max_height; }
_______________________________________________ nginx-ru mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx-ru
