Page 1 of 1

Watermarking Animated Gifs

Posted: 2009-07-07T16:15:56-07:00
by Ackergaul
Hello,
I just installed IMagick and was wondering if there is a way to watermark and resize animated gifs.

Best,
Ackergaul

Re: Watermarking Animated Gifs

Posted: 2009-07-24T15:52:24-07:00
by mkoppanen
Hello,

sure! you just need to execute the operations on every frame:

Code: Select all


$im = new Imagick("test.gif");

foreach ($im as $frame) {
  
  // resize and watermark $frame here

}

$im->writeImages( ...


Re: Watermarking Animated Gifs

Posted: 2009-08-06T18:25:00-07:00
by anthony
If you want to compose on every frame you should be able to use the multi-image
CompositeLayers() function. This should take two images lists whcih it alpha composes together. if one of the images is only a single image that image is applied to ALL the images of the other list.

I implemented this for Command Line (-layers composite), but it should be available for other API's by this time.

WARNING: for GIF animations be sure to Coalesce the animation to remove any optimizations thet may be present, or unexpected results may occur.

After processing you can use the functions OptimizeImageLayers() for frame disposal optimization, and then OptimizeImageTransparency() for to make it compress better.

See the three sections on GIF Animations, in the Command Line API usage guide, IM Examples. They are recommended reading for anyone doing GIF animation work.
http://www.imagemagick.org/Usage/