changeset 3133:28a6aa24b453

fix alpha-channel transparency in PNG
author Igor Sysoev <igor@sysoev.ru>
date Tue, 15 Sep 2009 09:47:12 +0000
parents 6cb238e091a9
children e6f5cb5eff8b
files src/http/modules/ngx_http_image_filter_module.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);