From: Cristy Date: Fri, 9 Dec 2016 15:40:04 +0000 (-0500) Subject: Enable alpha channel if background color is non-opaque X-Git-Tag: 7.0.3-10~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a739e8f74eed904807e288615a94479fdc110c94;p=imagemagick Enable alpha channel if background color is non-opaque --- diff --git a/ChangeLog b/ChangeLog index b51477ebe..f75b90662 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=29105). * Respect connected-components:area-threshold define (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31006). + * Enable alpha channel if background color is non-opaque (reference + https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31016). 2016-12-05 7.0.3-9 Cristy * Release ImageMagick version 7.0.3-9, GIT revision 19139:6fed3f1:20161205. diff --git a/MagickCore/image.c b/MagickCore/image.c index 685d3acea..ae1f3a20e 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -49,6 +49,7 @@ #include "MagickCore/cache.h" #include "MagickCore/cache-private.h" #include "MagickCore/cache-view.h" +#include "MagickCore/channel.h" #include "MagickCore/client.h" #include "MagickCore/color.h" #include "MagickCore/color-private.h" @@ -2240,6 +2241,9 @@ MagickExport MagickBooleanType SetImageBackgroundColor(Image *image, assert(image->signature == MagickCoreSignature); if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) return(MagickFalse); + if ((image->background_color.alpha != OpaqueAlpha) && + (image->alpha_trait == UndefinedPixelTrait)) + (void) SetImageAlphaChannel(image,OnAlphaChannel,exception); ConformPixelInfo(image,&image->background_color,&background,exception); /* Set image background color.