Mogrify and convert not working how I think they should

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
robertmy

Mogrify and convert not working how I think they should

Post by robertmy »

Using the help here I found this command to convert a png to a gif and still have it look halfway decent:

convert source.png -background #FFFFFF -flatten -fuzz 10% -transparent #FFFFFF target.gif

Now I want to convert a whole mess of png's with mogrify instead like this:

mogrify -format gif -background #FFFFFF -flatten -fuzz 10% -transparent #FFFFFF *.png

It doesn't produce the same result. In the convert case I get an image with transparency and a ring of background color in the semi-transparent pixels. In the mogrify case there is no transparency.

I'm using:
Version: ImageMagick 6.5.3-8 2009-06-16 Q8 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify and convert not working how I think they should

Post by fmw42 »

this came up in another forum recently and the response was:
Anthony wrote:Sorry -flatten is not usable from mogrify...

use
-bordercolor white -border 0
instead
but your command is a bit strange for just a conversion.
convert source.png -background #FFFFFF -flatten -fuzz 10% -transparent #FFFFFF target.gif
Can you clarify why you flatten transparency only to put it back again? Are you doing this because PNG allows 8-bit transparency and GIF only allows 1-bit (binary) transparency?


If so you might also try:

convert image.png -channel a -threshold XX% -channel rgba image.gif

and if that works, then try it in mogrify
robertmy

Re: Mogrify and convert not working how I think they should

Post by robertmy »

I found the command line in the ImageMagick help here:
http://www.imagemagick.org/Usage/formats/#bg_pattern

The reason for all this is what you suspected which is the 1 bit alpha problem of gifs. I'm stuck needing to use gifs, but I still want some transparency. I realized that my initial convert command line doesn't work either. If the icon has white in it my convert command makes it transparent too. I'll give your alpha idea a try.

Thanks for the help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify and convert not working how I think they should

Post by fmw42 »

I found the command line in the ImageMagick help here:
http://www.imagemagick.org/Usage/formats/#bg_pattern
-flatten is fine with convert, but apparently not usable with mogrify, thus the work around I mentioned that came from Anthony on another post elsewhere.
Post Reply