comparison src/http/modules/ngx_http_image_filter_module.c @ 5052:f2dcb25987df stable-1.2

Merge of r4979, r4982: image filter configuration inheritance. *) Image filter: configuration inheritance fixes. The image_filter_jpeg_quality, image_filter_sharpen and "image_filter rotate" were inherited incorrectly if a directive with variables was defined, and then redefined to a literal value, i.e. in configurations like image_filter_jpeg_quality $arg_q; location / { image_filter_jpeg_quality 50; } Patch by Ian Babrou, with minor changes. *) 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.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 11 Feb 2013 13:59:08 +0000
parents 084137d883ec
children
comparison
equal deleted inserted replaced
5051:4c3c409ed306 5052:f2dcb25987df
1167 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_image_filter_conf_t)); 1167 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_image_filter_conf_t));
1168 if (conf == NULL) { 1168 if (conf == NULL) {
1169 return NULL; 1169 return NULL;
1170 } 1170 }
1171 1171
1172 /*
1173 * set by ngx_pcalloc():
1174 *
1175 * conf->width = 0;
1176 * conf->height = 0;
1177 * conf->angle = 0;
1178 * conf->wcv = NULL;
1179 * conf->hcv = NULL;
1180 * conf->acv = NULL;
1181 * conf->jqcv = NULL;
1182 * conf->shcv = NULL;
1183 */
1184
1172 conf->filter = NGX_CONF_UNSET_UINT; 1185 conf->filter = NGX_CONF_UNSET_UINT;
1173 conf->jpeg_quality = NGX_CONF_UNSET_UINT; 1186 conf->jpeg_quality = NGX_CONF_UNSET_UINT;
1174 conf->sharpen = NGX_CONF_UNSET_UINT; 1187 conf->sharpen = NGX_CONF_UNSET_UINT;
1175 conf->angle = NGX_CONF_UNSET_UINT;
1176 conf->transparency = NGX_CONF_UNSET; 1188 conf->transparency = NGX_CONF_UNSET;
1177 conf->buffer_size = NGX_CONF_UNSET_SIZE; 1189 conf->buffer_size = NGX_CONF_UNSET_SIZE;
1178 1190
1179 return conf; 1191 return conf;
1180 } 1192 }
1193 1205
1194 } else { 1206 } else {
1195 conf->filter = prev->filter; 1207 conf->filter = prev->filter;
1196 conf->width = prev->width; 1208 conf->width = prev->width;
1197 conf->height = prev->height; 1209 conf->height = prev->height;
1210 conf->angle = prev->angle;
1198 conf->wcv = prev->wcv; 1211 conf->wcv = prev->wcv;
1199 conf->hcv = prev->hcv; 1212 conf->hcv = prev->hcv;
1200 } 1213 conf->acv = prev->acv;
1201 } 1214 }
1202 1215 }
1203 /* 75 is libjpeg default quality */ 1216
1204 ngx_conf_merge_uint_value(conf->jpeg_quality, prev->jpeg_quality, 75); 1217 if (conf->jpeg_quality == NGX_CONF_UNSET_UINT) {
1205 1218
1206 if (conf->jqcv == NULL) { 1219 /* 75 is libjpeg default quality */
1207 conf->jqcv = prev->jqcv; 1220 ngx_conf_merge_uint_value(conf->jpeg_quality, prev->jpeg_quality, 75);
1208 } 1221
1209 1222 if (conf->jqcv == NULL) {
1210 ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0); 1223 conf->jqcv = prev->jqcv;
1211 1224 }
1212 if (conf->shcv == NULL) { 1225 }
1213 conf->shcv = prev->shcv; 1226
1214 } 1227 if (conf->sharpen == NGX_CONF_UNSET_UINT) {
1215 1228 ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0);
1216 ngx_conf_merge_uint_value(conf->angle, prev->angle, 0); 1229
1217 if (conf->acv == NULL) { 1230 if (conf->shcv == NULL) {
1218 conf->acv = prev->acv; 1231 conf->shcv = prev->shcv;
1232 }
1219 } 1233 }
1220 1234
1221 ngx_conf_merge_value(conf->transparency, prev->transparency, 1); 1235 ngx_conf_merge_value(conf->transparency, prev->transparency, 1);
1222 1236
1223 ngx_conf_merge_size_value(conf->buffer_size, prev->buffer_size, 1237 ngx_conf_merge_size_value(conf->buffer_size, prev->buffer_size,