PNG forced to grayscale?

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
Naerymdan
Posts: 2
Joined: 2011-02-03T19:28:53-07:00
Authentication code: 8675308

PNG forced to grayscale?

Post by Naerymdan »

I have a PNG image in RGBA format (The whole TrueColorMatte thing) and try to trim it (and repage it) and save it back as indexed (palette) with:

convert splash.png -trim +repage -type PaletteMatte newSplash.png
convert splash.png -trim +repage -type Palette newSplash.png
convert splash.png -trim +repage -define png:color-type=3 newSplash.png

But it consistently saves it as Grayscale no matter what I use. While it could seem that grayscale is like indexed but with white to black, IT'S NOT! It uses luminance and really plays badly with my rendering engine.

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

Re: PNG forced to grayscale?

Post by fmw42 »

what IM version and platform? perhaps you need to upgrade.

there have been many changes going on with PNG. see http://www.imagemagick.org/script/changelog.php




When I tried to do something similar on IM 6.6.7.4 Q16 Mac OSX Tiger, I still get a color image, but the transparency is lost.

convert logo: -resize 50% -transparent white -alpha on -channel rgba -trim +repage -type palettematte PNG8:logo_test.png

or even

convert logo: -resize 50% -transparent white -alpha on -channel rgba -type palettematte PNG8:logo_test.png

or even

convert logo: -transparent white -type palettematte PNG8:logo_test.png


In all 3 cases, the result is still color and palette, but transparency has turned black or is not created leaving white background.



Interestingly, this works:

convert logo: -transparent white gif:- | convert - -type palettematte PNG8:logo_test.png


But this does not:

convert logo: -transparent white miff:- | convert - -type palettematte PNG8:logo_test.png
Naerymdan
Posts: 2
Joined: 2011-02-03T19:28:53-07:00
Authentication code: 8675308

Re: PNG forced to grayscale?

Post by Naerymdan »

I'm using the latest and greatest 6.6.7-4, but I had the same problem with my 'old' 6.5.4-7
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PNG forced to grayscale?

Post by glennrp »

Please send the original spash.png to glennrp at imagemagick.org or post a URL to it and I'll see if I can figure out what went wrong.

Verified that fred's last test case fails to preserve the transparency that exists in the MIFF.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG forced to grayscale?

Post by fmw42 »

glennrp wrote: Verified that fred's last test case fails to preserve the transparency that exists in the MIFF.
Glenn,

This does not work either.


convert logo: logo.png
convert logo.png -transparent white -type palettematte PNG8:logo_test.png

Background remains white -- no transparency

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

Re: PNG forced to grayscale?

Post by glennrp »

This was continued in
viewtopic.php?f=3&t=18074
The transparency also gets lost when you write to a MIFF instead of a PNG,
so the bug seems to lie in the palettematte conversion before the encoder is called.
Post Reply