image_filter configuration inheritance
ivan babrou
ibobrik at gmail.com
Thu Dec 20 16:52:30 UTC 2012
For now nginx ignore explicit configuration of some image_filter directives.
For example, in this case nginx will use jpeg quality 10 instead of 80:
server {
listen 8080;
root /home/bobrik/dev;
set $arg_q 10;
image_filter_jpeg_quality $arg_q;
location / {
image_filter_jpeg_quality 80;
image_filter crop 128 128;
}
}
Maxim pointed me how to fix it, so here's the patch to fix it:
diff --git a/ngx_http_image_filter_module.c b/ngx_http_image_filter_module.c
index c853c33..3aee1a4 100644
--- a/ngx_http_image_filter_module.c
+++ b/ngx_http_image_filter_module.c
@@ -1201,21 +1201,28 @@ ngx_http_image_filter_merge_conf(ngx_conf_t *cf,
void *parent, void *child)
}
/* 75 is libjpeg default quality */
- ngx_conf_merge_uint_value(conf->jpeg_quality, prev->jpeg_quality, 75);
+ if (conf->jpeg_quality == NGX_CONF_UNSET_UINT) {
+ ngx_conf_merge_uint_value(conf->jpeg_quality, prev->jpeg_quality,
75);
- if (conf->jqcv == NULL) {
- conf->jqcv = prev->jqcv;
+ if (conf->jqcv == NULL) {
+ conf->jqcv = prev->jqcv;
+ }
}
- ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0);
+ if (conf->sharpen == NGX_CONF_UNSET_UINT) {
+ ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0);
- if (conf->shcv == NULL) {
- conf->shcv = prev->shcv;
+ if (conf->shcv == NULL) {
+ conf->shcv = prev->shcv;
+ }
}
- 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);
--
Regards, Ian Babrou
http://bobrik.name http://twitter.com/ibobrik skype:i.babrou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20121220/7edbf74b/attachment.html>
More information about the nginx-devel
mailing list