# HG changeset patch # User Igor Sysoev # Date 1253008032 0 # Node ID 28a6aa24b45398ae736485bb2e8eee11cecc77cf # Parent 6cb238e091a9a87dc7f5e08c5e213f2d647ab583 fix alpha-channel transparency in PNG 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 @@ -768,6 +768,11 @@ ngx_http_image_resize(ngx_http_request_t return NULL; } + if (colors == 0) { + gdImageSaveAlpha(dst, 1); + gdImageAlphaBlending(dst, 0); + } + gdImageCopyResampled(dst, src, 0, 0, 0, 0, dx, dy, sx, sy); gdImageDestroy(src); @@ -810,6 +815,11 @@ ngx_http_image_resize(ngx_http_request_t "image crop: %d x %d @ %d x %d", dx, dy, ox, oy); + if (colors == 0) { + gdImageSaveAlpha(dst, 1); + gdImageAlphaBlending(dst, 0); + } + gdImageCopy(dst, src, 0, 0, ox, oy, dx - ox, dy - oy); gdImageDestroy(src);