]> git.kaiwu.me - nginx.git/commitdiff
fix alpha-channel transparency in PNG
authorIgor Sysoev <igor@sysoev.ru>
Tue, 15 Sep 2009 09:47:12 +0000 (09:47 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 15 Sep 2009 09:47:12 +0000 (09:47 +0000)
src/http/modules/ngx_http_image_filter_module.c

index 653cc791bafd48609629e7a0a1329420a0492277..70b27310cedca1183e9fd993e904012fb099816a 100644 (file)
@@ -768,6 +768,11 @@ ngx_http_image_resize(ngx_http_request_t *r, ngx_http_image_filter_ctx_t *ctx)
             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 *r, ngx_http_image_filter_ctx_t *ctx)
                            "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);