aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-09-12 09:46:28 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-09-12 09:46:28 +0000
commit79b8049de4f10e2536f18110834620eb1b50b6ab (patch)
tree3299e3df2cb6653a5980fdad23b183c01f5f23fd
parent96e36ef25243d7f49d821dbf8e47937ddbdea3f6 (diff)
downloadnginx-79b8049de4f10e2536f18110834620eb1b50b6ab.tar.gz
nginx-79b8049de4f10e2536f18110834620eb1b50b6ab.zip
fix transparency in GIF
-rw-r--r--src/http/modules/ngx_http_image_filter_module.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
index 4af2912c7..653cc791b 100644
--- a/src/http/modules/ngx_http_image_filter_module.c
+++ b/src/http/modules/ngx_http_image_filter_module.c
@@ -679,7 +679,7 @@ static ngx_buf_t *
ngx_http_image_resize(ngx_http_request_t *r, ngx_http_image_filter_ctx_t *ctx)
{
int sx, sy, dx, dy, ox, oy,
- colors, transparent, size;
+ colors, transparent, red, green, blue, size;
u_char *out;
ngx_buf_t *b;
ngx_uint_t resize;
@@ -708,6 +708,16 @@ ngx_http_image_resize(ngx_http_request_t *r, ngx_http_image_filter_ctx_t *ctx)
colors = gdImageColorsTotal(src);
transparent = gdImageGetTransparent(src);
+ if (transparent != -1 && colors) {
+ red = gdImageRed(src, transparent);
+ green = gdImageGreen(src, transparent);
+ blue = gdImageBlue(src, transparent);
+ gdImageColorTransparent(src, -1);
+
+ } else {
+ red = 0; green = 0; blue = 0;
+ }
+
dx = sx;
dy = sy;
@@ -806,7 +816,9 @@ ngx_http_image_resize(ngx_http_request_t *r, ngx_http_image_filter_ctx_t *ctx)
}
}
- gdImageColorTransparent(dst, transparent);
+ if (transparent != -1 && colors) {
+ gdImageColorTransparent(dst, gdImageColorExact(dst, red, green, blue));
+ }
out = ngx_http_image_out(r, ctx->type, dst, &size);