PNG with duplicate palette entries causes corrupt output

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
xrw

PNG with duplicate palette entries causes corrupt output

Post by xrw »

Code: Select all

~ $ convert in.png png8:out.png
~ $ convert -version
Version: ImageMagick 6.4.2 06/29/08 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
~ $ uname -a
Linux local 2.6.24-gentoo-r3-v1 #1 Sun Mar 2 06:05:48 CET 2008 x86_64 AMD Athlon(tm) 64 Processor 3500+ AuthenticAMD GNU/Linux
The input PNG (created with GrADS) has duplicate entries in its palette. ImageMagick seems to try to collapse them in the output PNG, but probably just removes the duplicate palette entries and fails to adjust the indices that refer to them.

I haven't verified the exact code, but the contours in the example image have the wrong color after processing and the color differs between viewers, whereas the shaded areas with the same color (but different palette index) remain intact.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG with duplicate palette entries causes corrupt output

Post by glennrp »

Does it work if you use "-type palette" ?
xrw

Re: PNG with duplicate palette entries causes corrupt output

Post by xrw »

Code: Select all

~ $ convert in.png png8:out.png
~ $ convert -type palette in.png png8:out2.png
~ $ diff -s out.png out2.png
Files out.png and out2.png are identical
xrw

Re: PNG with duplicate palette entries causes corrupt output

Post by xrw »

Has somebody noticed this bug? It's still present in 6.4.3-0.
xrw

Re: PNG with duplicate palette entries causes corrupt output

Post by xrw »

The fix from another bug seems to have fixed this too.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: PNG with duplicate palette entries causes corrupt output

Post by anthony »

WARNING: if you do any processing of a pallette image, generally all the color entries will be collapsed as the pallete is re-recreated from the actual image colors.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply