image_filter configuration inheritance
Maxim Dounin
mdounin at mdounin.ru
Thu Dec 20 20:10:43 UTC 2012
Hello!
On Thu, Dec 20, 2012 at 08:52:30PM +0400, ivan babrou wrote:
> For now nginx ignore explicit configuration of some image_filter directives.
[...]
> - ngx_conf_merge_uint_value(conf->angle, prev->angle, 0);
> - if (conf->acv == NULL) {
> - conf->acv = prev->acv;
> + if (conf->angle == NGX_CONF_UNSET_UINT) {
> + ngx_conf_merge_uint_value(conf->angle, prev->angle, 0);
> +
> + if (conf->acv == NULL) {
> + conf->acv = prev->acv;
> + }
> }
>
> ngx_conf_merge_value(conf->transparency, prev->transparency, 1);
Thanks, committed with minor changes. Could you please provide
proper Russian transcription of your name for CHANGES.ru?
While writing the commit message for the patch, I've realized that
conf->angle/conf->acv inheritance looks wrong even with your
patch.
Suggested additional patch below. Is it looks ok?
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1356029439 -14400
# Node ID 7cb7b792d932c4e95b85db964993b9e883973608
# Parent 4c61fe6fa25dd38df68b7952281716e26a7b4618
Image filter: fixed image_filter rotate inheritance.
Configurations like
location /i/ {
image_filter resize 200 200;
image_filter rotate 180;
location /i/foo/ {
image_filter resize 200 200;
}
}
resulted in rotation incorrectly applied in the location /i/foo, without
any way to clear it. Fix is to handle conf->angle/conf->acv consistently
with other filter variables and do not try to inherit them if there are
transformations defined for current location.
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
--- a/src/http/modules/ngx_http_image_filter_module.c
+++ b/src/http/modules/ngx_http_image_filter_module.c
@@ -1169,10 +1169,22 @@ ngx_http_image_filter_create_conf(ngx_co
return NULL;
}
+ /*
+ * set by ngx_pcalloc():
+ *
+ * conf->width = 0;
+ * conf->height = 0;
+ * conf->angle = 0;
+ * conf->wcv = NULL;
+ * conf->hcv = NULL;
+ * conf->acv = NULL;
+ * conf->jqcv = NULL;
+ * conf->shcv = NULL;
+ */
+
conf->filter = NGX_CONF_UNSET_UINT;
conf->jpeg_quality = NGX_CONF_UNSET_UINT;
conf->sharpen = NGX_CONF_UNSET_UINT;
- conf->angle = NGX_CONF_UNSET_UINT;
conf->transparency = NGX_CONF_UNSET;
conf->buffer_size = NGX_CONF_UNSET_SIZE;
@@ -1195,8 +1207,10 @@ ngx_http_image_filter_merge_conf(ngx_con
conf->filter = prev->filter;
conf->width = prev->width;
conf->height = prev->height;
+ conf->angle = prev->angle;
conf->wcv = prev->wcv;
conf->hcv = prev->hcv;
+ conf->acv = prev->hcv;
}
}
@@ -1218,14 +1232,6 @@ ngx_http_image_filter_merge_conf(ngx_con
}
}
- if (conf->angle == NGX_CONF_UNSET_UINT) {
- ngx_conf_merge_uint_value(conf->angle, prev->angle, 0);
-
- if (conf->acv == NULL) {
- conf->acv = prev->acv;
- }
- }
-
ngx_conf_merge_value(conf->transparency, prev->transparency, 1);
ngx_conf_merge_size_value(conf->buffer_size, prev->buffer_size,
--
Maxim Dounin
http://nginx.com/support.html
p.s. It looks like your mail client corrupts patches, I had to fix
line wrapping manually to apply your patch. You may also want to
avoid posting html emails here, thnx.
More information about the nginx-devel
mailing list