Page 1 of 1

PNG with duplicate palette entries causes corrupt output

Posted: 2008-07-14T06:08:15-07:00
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.

Re: PNG with duplicate palette entries causes corrupt output

Posted: 2008-07-14T08:09:14-07:00
by glennrp
Does it work if you use "-type palette" ?

Re: PNG with duplicate palette entries causes corrupt output

Posted: 2008-07-14T08:24:30-07:00
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

Re: PNG with duplicate palette entries causes corrupt output

Posted: 2008-08-20T13:12:26-07:00
by xrw
Has somebody noticed this bug? It's still present in 6.4.3-0.

Re: PNG with duplicate palette entries causes corrupt output

Posted: 2008-08-20T19:38:53-07:00
by xrw
The fix from another bug seems to have fixed this too.

Re: PNG with duplicate palette entries causes corrupt output

Posted: 2008-08-21T17:11:00-07:00
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.