PNG color is wrong but GIF is right

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Santa911
Posts: 11
Joined: 2011-04-20T23:24:46-07:00
Authentication code: 8675308

PNG color is wrong but GIF is right

Post by Santa911 »

Hi, I'm trying to make some small icons with a certaing HEX color. It works quite well for most of the hex codes I have processed, but for the hex color "FFCC00" it does not work, when I converts it to PNG. However the "same" code works for GIF formats.

Why is that - Can somebody explain this and hopefully help me converting to right color for PNG?

GIF - Works fine (turns yellow)

Code: Select all

convert -size 30x24 canvas:#ffcc00 Box0030x0024_FFCC00.gif
PNG - Does not work (turns black)

Code: Select all

convert -size 30x24 canvas:#ffcc00 Box0030x0024_FFCC00.png
PS. What is the difference when using "canvas" instead of "xc". Both things works on the above.

Lars
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG color is wrong but GIF is right

Post by fmw42 »

There have been some colorspace changes going on since IM 6.7.5.5 that may only now have been fully resolved. You don't say what release you are using. So you may want to upgrade to the latest release and give that a try.

canvas: and xc: are the same thing (just a name change as xc: was not as descriptive as canvas:) both are still valid
Santa911
Posts: 11
Joined: 2011-04-20T23:24:46-07:00
Authentication code: 8675308

Re: PNG color is wrong but GIF is right

Post by Santa911 »

Thanx. I am using Win7 and have been using the latest version (ImageMagick-6.7.7-9-Q16-windows-dll.exe). Maybe I should downgrade instead :shock:

If you are uncertain you can self give it a try with the code descriped - it's only one commandline to test (twice) but with a different result.

Lars
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG color is wrong but GIF is right

Post by fmw42 »

I am using IM 6.7.7.9 Q16 (hdri) Mac OSX Snow Leopard and your two commands produce exactly the same results for me. Might it be your viewer?

Perhaps it is a Windows issue? Maybe one of the other Windows users could verify and report back.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: PNG color is wrong but GIF is right

Post by anthony »

The image turning black is a serious bug of some kind.
It should not happen.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG color is wrong but GIF is right

Post by glennrp »

The PNG encoder was not expanding the PLTE chunk to accommodate the background color in indexed PNG output. Fixed in IM-6.7.7-10, SVN revision 8520 and 8521.
Santa911
Posts: 11
Joined: 2011-04-20T23:24:46-07:00
Authentication code: 8675308

Re: PNG color is wrong but GIF is right

Post by Santa911 »

Sounds good with the fix in version 6.7.7-10, but on the webpage the newest version is still ImageMagick-6.7.7-9 (2012-06-28). Any idea on when the new version for Windows is released?

Lars
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG color is wrong but GIF is right

Post by glennrp »

IM-6.7.7-10 is out today 28 June.
Santa911
Posts: 11
Joined: 2011-04-20T23:24:46-07:00
Authentication code: 8675308

Re: PNG color is wrong but GIF is right

Post by Santa911 »

Nope, does still not work in version 10 (ImageMagick-6.7.7-10-Q16-windows-dll.exe). Following command still creates a black rectangle :(

Code: Select all

convert -size 30x24 canvas:#ffcc00 Box0030x0024_FFCC00.png
Hope that this will be fixed in future versions.

Lars
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG color is wrong but GIF is right

Post by glennrp »

Some of the IM-6.7.7-10 Windows executables at SourceForge were built a few minutes
before the PNG patch was applied. I did not notice that problem until this morning.
The IM-6.7.7-10 executables at SourceForge are up to date now.
Santa911
Posts: 11
Joined: 2011-04-20T23:24:46-07:00
Authentication code: 8675308

Re: PNG color is wrong but GIF is right

Post by Santa911 »

Thanx - Now it works, you're help is appreciated. Great program by the way. Combined with programming I find it find a very useful tool for smaller tasks ex Watermarks and generation of icons etc.

Lars
Post Reply