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