[nginx] svn commit: r4356 - in branches/stable-1.0: . src/http/modules
mdounin at mdounin.ru
mdounin at mdounin.ru
Wed Dec 14 13:37:53 UTC 2011
Author: mdounin
Date: 2011-12-14 13:37:53 +0000 (Wed, 14 Dec 2011)
New Revision: 4356
Log:
Merge of r4266, r4308, r4309:
Image filter changes:
*) The "image_filter_sharpen" directive.
*) Cosmetics.
*) Fixed "rotate" to always work when combined with "resize/crop".
Modified:
branches/stable-1.0/
branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c
Property changes on: branches/stable-1.0
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265,4268,4280,4283,4300,4303-4304,4321,4342-4343
+ /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4266,4268,4280,4283,4300,4303-4304,4308-4309,4321,4342-4343
Modified: branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c
===================================================================
--- branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c 2011-12-14 13:34:16 UTC (rev 4355)
+++ branches/stable-1.0/src/http/modules/ngx_http_image_filter_module.c 2011-12-14 13:37:53 UTC (rev 4356)
@@ -41,6 +41,7 @@
ngx_uint_t height;
ngx_uint_t angle;
ngx_uint_t jpeg_quality;
+ ngx_uint_t sharpen;
ngx_flag_t transparency;
@@ -48,6 +49,7 @@
ngx_http_complex_value_t *hcv;
ngx_http_complex_value_t *acv;
ngx_http_complex_value_t *jqcv;
+ ngx_http_complex_value_t *shcv;
size_t buffer_size;
} ngx_http_image_filter_conf_t;
@@ -105,13 +107,15 @@
void *conf);
static char *ngx_http_image_filter_jpeg_quality(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
+static char *ngx_http_image_filter_sharpen(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
static ngx_int_t ngx_http_image_filter_init(ngx_conf_t *cf);
static ngx_command_t ngx_http_image_filter_commands[] = {
{ ngx_string("image_filter"),
- NGX_HTTP_LOC_CONF|NGX_CONF_TAKE13|NGX_CONF_TAKE2,
+ NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
ngx_http_image_filter,
NGX_HTTP_LOC_CONF_OFFSET,
0,
@@ -124,6 +128,13 @@
0,
NULL },
+ { ngx_string("image_filter_sharpen"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_image_filter_sharpen,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
{ ngx_string("image_filter_transparency"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
@@ -724,7 +735,7 @@
ngx_http_image_resize(ngx_http_request_t *r, ngx_http_image_filter_ctx_t *ctx)
{
int sx, sy, dx, dy, ox, oy, ax, ay, size,
- colors, palette, transparent,
+ colors, palette, transparent, sharpen,
red, green, blue, t;
u_char *out;
ngx_buf_t *b;
@@ -948,6 +959,11 @@
gdImageColorTransparent(dst, gdImageColorExact(dst, red, green, blue));
}
+ sharpen = ngx_http_image_filter_get_value(r, conf->shcv, conf->sharpen);
+ if (sharpen > 0) {
+ gdImageSharpen(dst, sharpen);
+ }
+
out = ngx_http_image_out(r, ctx->type, dst, &size);
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1156,6 +1172,7 @@
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;
@@ -1191,6 +1208,12 @@
conf->jqcv = prev->jqcv;
}
+ ngx_conf_merge_uint_value(conf->sharpen, prev->sharpen, 0);
+
+ 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;
@@ -1239,7 +1262,11 @@
} else if (cf->args->nelts == 3) {
if (ngx_strcmp(value[i].data, "rotate") == 0) {
- imcf->filter = NGX_HTTP_IMAGE_ROTATE;
+ if (imcf->filter != NGX_HTTP_IMAGE_RESIZE
+ && imcf->filter != NGX_HTTP_IMAGE_CROP)
+ {
+ imcf->filter = NGX_HTTP_IMAGE_ROTATE;
+ }
ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
@@ -1382,7 +1409,7 @@
if (n <= 0) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "invalid parameter \"%V\"", &value[1]);
+ "invalid value \"%V\"", &value[1]);
return NGX_CONF_ERROR;
}
@@ -1401,6 +1428,53 @@
}
+static char *
+ngx_http_image_filter_sharpen(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf)
+{
+ ngx_http_image_filter_conf_t *imcf = conf;
+
+ ngx_str_t *value;
+ ngx_int_t n;
+ ngx_http_complex_value_t cv;
+ ngx_http_compile_complex_value_t ccv;
+
+ value = cf->args->elts;
+
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
+
+ ccv.cf = cf;
+ ccv.value = &value[1];
+ ccv.complex_value = &cv;
+
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+
+ if (cv.lengths == NULL) {
+ n = ngx_http_image_filter_value(&value[1]);
+
+ if (n < 0) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid value \"%V\"", &value[1]);
+ return NGX_CONF_ERROR;
+ }
+
+ imcf->sharpen = (ngx_uint_t) n;
+
+ } else {
+ imcf->shcv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t));
+ if (imcf->shcv == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ *imcf->shcv = cv;
+ }
+
+ return NGX_CONF_OK;
+}
+
+
static ngx_int_t
ngx_http_image_filter_init(ngx_conf_t *cf)
{
More information about the nginx-devel
mailing list