Page 1 of 1

How to remove white frames from animated GIF?

Posted: 2011-05-22T09:19:29-07:00
by pacificocean
Hello!

I have been searching around for a while to an answer to this question.
I am trying to merge an animated gif and watermark and sometimes i get gif with white frames, like this:

Image

Other gifs are obtained normally, like this:

Image

Does anybody know how to make them without this white frames?
Thanks a lot!

Re: How to remove white frames from animated GIF?

Posted: 2011-05-22T10:24:41-07:00
by fmw42
What version of IM and what platform? Can you post a link to your cat animation gif and the watermark image? What is your exact command line?

It is very hard to know what the problem is without such information.

Re: How to remove white frames from animated GIF?

Posted: 2011-05-22T16:39:01-07:00
by anthony
Your second animation looks fine to me. The first however...

It looks like an existing "transparency optimised" animation was incorrectly processed causing the optimization to become white!
OR the transparency index information was lost!

If the pure white is a unique color you could map that color to transparency,
Try this...
convert bad.gif -transparent white fixed.gif

Or use a lowlevel program like giftrans
http://www.ict.griffith.edu.au/~anthony ... /#giftrans
to find the white index and specify it as being transparent.

the latter will make the least impact on the animation but is harder to do

Hmmm that did not work right! the color is not always pure white, and the timings in the animation is horrible, relying on the web browser's minimal time sequence (bad idea). Display this in IM "animate" or some other GIF animator and you get the animation zipping through so fast it is all a blur!

The best idea is probably to unpack the animation into individual frames and animation meta-data using say "gif2anim"
http://www.imagemagick.org/Usage/scripts/gif2anim
fix each frame so the 'white' parts become transparent, the repack using the reverse "anim2gif"
http://www.imagemagick.org/Usage/scripts/anim2gif
examples of using this script is in IM examples, Animation Basics
http://www.imagemagick.org/Usage/anim_basics/#sequence
But is also used in Animation Modifications.

Re: How to remove white frames from animated GIF?

Posted: 2011-05-23T01:22:56-07:00
by pacificocean
anthony
Thank you very much! I'll try this!

fmw42
IM Version is 3.0.0, here is the code:

Code: Select all

       $im = new Imagick($filename);
       $im_width = $im->getImageWidth();
       $im_height = $im->getImageHeight();

       $wm = new Imagick(PATH.'/pikabu_logo.png');
       $wm_width = $wm->getImageWidth();
       $wm_height = $wm->getImageHeight();

       $x_offset = $im_width  - $wm_width;
       $y_offset = $im_height - $wm_height;

       foreach ($im as $frame) {
               $frame->compositeImage($wm, imagick::COMPOSITE_OVER,
$x_offset, $y_offset);
       }

Re: How to remove white frames from animated GIF?

Posted: 2011-05-23T09:39:09-07:00
by fmw42
Still need your original cat animation and the watermark image as separate links, so that I or someone else can test in command line to regenerate you final animation.