PNG and changes in -colors option from IM 6.5.7-8

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
skrandom

PNG and changes in -colors option from IM 6.5.7-8

Post by skrandom »

I'm currently using two separate versions of IM across two computers (dev environment vs server), using 6.5.7-8 on my desktop and 6.6.4-0 (the latest right now). Against a PNG with transparency, I use the -colors option to reduce the colours down and in 6.5.7-8, the transparency is maintained correctly, but in 6.6.4-0, the alpha appears to get stripped.

The command is:

Code: Select all

mogrify -colors 192 original.png
as the original image has 192 colours. My aim is to end up with an indexed PNG, to save on filesize, and the earlier IM works correctly and maintains the alpha, whilst the latter does not. My resultant images are below.

Original image:
Image
IM 6.5.7-8 result:
Image
IM 6.6.4-0 result:
Image

I've attempted going through the change log, but it doesn't mean much to me unfortunately. Is this a bug and/or else how can I maintain the same result?

Thanks in advance.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: PNG and changes in -colors option from IM 6.5.7-8

Post by Drarakel »

skrandom wrote:Is this a bug
Yes.
You can find other examples in that thread:
viewtopic.php?f=3&t=16490
(See e.g. case #15 on the first page. That was a simple image with 2 colors and binary transparency. With "-colors 3", the transparency was gone AND the transparent areas were replaced with the background color.)
skrandom wrote:how can I maintain the same result?
Don't make any attempt to create an indexed PNG with transparency in a current IM. :wink: Color reduction is also risky. After creating the (32 bit) PNGs with IM, you can process them with a Non-ImageMagick PNG tool.
Or: Use an older IM version, if that worked for you.
skrandom

Re: PNG and changes in -colors option from IM 6.5.7-8

Post by skrandom »

Drarakel wrote:
skrandom wrote:Is this a bug
Yes.
You can find other examples in that thread:
viewtopic.php?f=3&t=16490
(See e.g. case #15 on the first page. That was a simple image with 2 colors and binary transparency. With "-colors 3", the transparency was gone AND the transparent areas were replaced with the background color.)
Thanks for that. I'll keep an eye on that thread.
skrandom wrote:how can I maintain the same result?
Don't make any attempt to create an indexed PNG with transparency in a current IM. :wink: Color reduction is also risky. After creating the (32 bit) PNGs with IM, you can process them with a Non-ImageMagick PNG tool.
Or: Use an older IM version, if that worked for you.[/quote]

Both good suggestions except I'm limited in both situations as I'm seeking to run this on a clustered environment with specific packages/versions available. Using an older IM version could be problematic as well as I hit the bug with 1-colour PNG images in 6.5.7-8. Hmm..

I tried out pngnq from that link and it does the job perfectly; even saving 0.1 KB extra off the IM result. Always a good thing when you're talking millions of files... I'll see what I can do to utilise this.
Post Reply