Page 1 of 1

Mogrify and convert not working how I think they should

Posted: 2009-09-30T17:39:29-07:00
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

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

Posted: 2009-09-30T17:59:58-07:00
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

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

Posted: 2009-10-01T15:18:26-07:00
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.

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

Posted: 2009-10-01T16:49:30-07:00
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.