From c1e1b8711e5ba8c9128f561d23898c2ed968bf92 Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 21 May 2019 18:24:39 -0400 Subject: [PATCH] https://imagemagick.org/discourse-server/viewtopic.php?f=1&t=36067 --- coders/psd.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) 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"); /* -- 2.40.0