From: Cristy Date: Tue, 21 May 2019 22:24:39 +0000 (-0400) Subject: https://imagemagick.org/discourse-server/viewtopic.php?f=1&t=36067 X-Git-Tag: 7.0.8-47~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1e1b8711e5ba8c9128f561d23898c2ed968bf92;p=imagemagick https://imagemagick.org/discourse-server/viewtopic.php?f=1&t=36067 --- diff --git a/coders/psd.c b/coders/psd.c index a9d19a945..1b64bd5cc 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -2217,22 +2217,26 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception) psd_info.min_channels=4; (void) SetImageColorspace(image,CMYKColorspace,exception); } - else if ((psd_info.mode == BitmapMode) || (psd_info.mode == GrayscaleMode) || - (psd_info.mode == DuotoneMode)) - { - if (psd_info.depth != 32) - { - status=AcquireImageColormap(image,(size_t) (psd_info.depth < 16 ? - 256 : 65536),exception); - if (status == MagickFalse) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - if (image->debug != MagickFalse) - (void) LogMagickEvent(CoderEvent,GetMagickModule(), - " Image colormap allocated"); - } - psd_info.min_channels=1; - (void) SetImageColorspace(image,GRAYColorspace,exception); - } + else + if ((psd_info.mode == BitmapMode) || (psd_info.mode == GrayscaleMode) || + (psd_info.mode == DuotoneMode)) + { + if (psd_info.depth != 32) + { + status=AcquireImageColormap(image,(size_t) (psd_info.depth < 16 ? + 256 : 65536),exception); + if (status == MagickFalse) + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + if (image->debug != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " Image colormap allocated"); + } + psd_info.min_channels=1; + (void) SetImageColorspace(image,GRAYColorspace,exception); + } + else + if (psd_info.mode == IndexedMode) + psd_info.min_channels=1; if (psd_info.channels < psd_info.min_channels) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); /*