From 2aec332b88e93abe71bf22b294163f6020c3ed41 Mon Sep 17 00:00:00 2001 From: glennrp Date: Mon, 2 Jan 2012 20:16:54 +0000 Subject: [PATCH] Fix PNG encoder problem with -depth 12. --- coders/png.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/coders/png.c b/coders/png.c index 324b41a67..cf926929c 100644 --- a/coders/png.c +++ b/coders/png.c @@ -6745,13 +6745,19 @@ static Image *ReadMNGImage(const ImageInfo *image_info,ExceptionInfo *exception) #if (MAGICKCORE_QUANTUM_DEPTH > 16) /* PNG does not handle depths greater than 16 so reduce it even - * if lossy + * if lossy. */ if (image->depth > 16) image->depth=16; #endif #if (MAGICKCORE_QUANTUM_DEPTH > 8) + if (image->depth > 8) + { + /* To do: fill low byte properly */ + image->depth=16; + } + if (LosslessReduceDepthOK(image,exception) != MagickFalse) image->depth = 8; #endif @@ -7965,6 +7971,12 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, #endif #if (MAGICKCORE_QUANTUM_DEPTH > 8) + if (image->depth > 8) + { + /* To do: fill low byte properly */ + image->depth=16; + } + if (image->depth == 16 && mng_info->write_png_depth != 16) if (mng_info->write_png8 || LosslessReduceDepthOK(image,exception) != MagickFalse) image->depth = 8; @@ -11739,6 +11751,9 @@ static MagickBooleanType WriteOneJNGImage(MngInfo *mng_info, (void) CopyMagickString(jpeg_image->magick,"PNG",MaxTextExtent); jpeg_image_info->interlace=NoInterlace; + /* Exclude all ancillary chunks */ + (void) SetImageArtifact(jpeg_image,"png:exclude-chunks","all"); + blob=ImageToBlob(jpeg_image_info,jpeg_image,&length, exception); -- 2.40.0