Add watermark on gif animation

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
userman
Posts: 12
Joined: 2010-09-12T10:58:46-07:00
Authentication code: 8675308

Add watermark on gif animation

Post by userman »

Hi,

I use in my script for add the watermark this:

#Adding watermark
exec('composite -gravity SouthEast images/logo-watermark.png '.$imagesurse2.' '.$imagesurse2);

but this dont work with gif animation :(


what i must add or change for work with gif animation?

Regards.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Add watermark on gif animation

Post by Bonzo »

Image
I have only tried this once and used:

Code: Select all

<?php
$animation = "morph.gif";

$watermark = "output.png";

$watermarked_animation = "morph.gif";

exec("convert -resize 100x200 $animation -coalesce -gravity South  -geometry +0+0 null: $watermark -layers composite -layers optimize $watermarked_animation ");
?> 

This is resizing the gif as well - just leave out the resize part.
The gif only loops once if you refresh the page it should loop again.
userman
Posts: 12
Joined: 2010-09-12T10:58:46-07:00
Authentication code: 8675308

Re: Add watermark on gif animation

Post by userman »

Thanks bonzo!!

I use it for the png and gif, this work good but when the file is created, the file have bad quality, why?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Add watermark on gif animation

Post by anthony »

WARNING:
read and coalesce the animation BEFORE using -resize.

See IM examples, Animation Modifications, Resize
http://www.imagemagick.org/Usage/anim_mods/#resize

If you don't and your animation has any form of optimization such as 'frame' or 'transparency', then it will go screwy!!! It only worked in your case as your 'morphed' animation is already a coalesced animation.

See Animation Types. Also look at Animation Optimizations, to get an idea of what these optimizations are
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
userman
Posts: 12
Joined: 2010-09-12T10:58:46-07:00
Authentication code: 8675308

Re: Add watermark on gif animation

Post by userman »

Thanks Anthony,

I use:
exec("convert $imagesurse2 -coalesce -gravity SouthEast -geometry +0+0 null: images/logo-watermark.png -layers composite -layers optimize $imagesurse2 ");

but i use this code for gif animation and for NO gif animations too, because i have this code the last file that generate all the images...

how can i change the code for get good quality for the files gif and not gif...

Thanks for the help!! this forum is great!!

Regards.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Add watermark on gif animation

Post by anthony »

The actions for GIF animations should not effect a single GIF file, unless you specifically
modify GIF animation attributes, such as -loop or -delay

You should be able to use the same command no problem.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Add watermark on gif animation

Post by Bonzo »

Thanks for the warning Anthony; I must have just been lucky with the original file format as you said!
Post Reply