Page 1 of 1

Re: Delete or exchange background color of animated gif?

Posted: 2008-12-14T18:25:52-07:00
by anthony
All three images contain 'shadow effects'.

these are the gray regions under or around the main object in the image, and those are tied to the background color.

Basically if you want to make the white background transparent, the 'shadow effects' would have to be made semi-transparent, which is NOT posible to do in GIF images.

GIF animations with shadow effects MUST be tied into some specific background or background color, or dithered in some way to allow the background to show through.

See IM Examples, Common File Formats, GIF, Background
http://www.imagemagick.org/Usage/formats/#bgnd
for just ONE frame of a GIF.

And Semi-transparency handling for GIF animation Optimization
http://www.imagemagick.org/Usage/anim_o ... itrans_opt
for various dithering methods you can use to handle.

You may especially like to look at Ordered Dithering Techniques
http://www.imagemagick.org/Usage/quanti ... red-dither

Now for extracting the shadow effect from the white background.
There are a number of ways. But as you are doing this on white, I can say you will have a easier time.

Basically mask out the 'opaque areas' then convert shadows di transparency and color them black. This is similar to the non-white double-thresholding method given in
http://www.imagemagick.org/Usage/channe ... antialised

Though it is simpler, I have not created an example for it yet.



In Summery, you will have to figure out how you want to handle 'shadow effects', the best method being to tie the animation to a specific background color or a rough background pattern.

Re: Delete or exchange background color of animated gif?

Posted: 2008-12-14T18:36:00-07:00
by anthony
Note the other problem you have is you have not re-optimized the separate images for transparency.

Add a -layers optimize before saving the modified images. And for completeness with 'wierder' GIF animations add a
-layers coalesce after reading the animation!

convert 36_11_7.gif -layers coalesce -background "#cccccc"
-fuzz 15% -draw "fill none matte 0,0 floodfill"
-transparent-color "#ffffff" -layers optimize test_output.gif

see IM Examples, Animation Basics for an understanding of these options, and the first few examples of Animation Modifications as to why you need them.

Basically read the three sections on GIF animations, if you really want to work with animations, so that you will know what you are doing!