Page 1 of 1

watermark on gif animation

Posted: 2007-10-20T14:04:23-07:00
by tiaggo
Hi,

I know some websites that have watermark image (with the name of the site) on bottom of the images.

I'm trying for 1 week now but all without success.

The original file:
http://img263.imageshack.us/img263/9960/01pn0.gif

I use this command to create a empty area in the bottom of the image:
convert $currentfile -coalesce -gravity South -background transparent -splice 0x18 -layers Optimize $newfile

The image created:
http://img212.imageshack.us/img212/2995/02rx6.gif

Here the watermark example:
http://img146.imageshack.us/img146/9829/sitenamerb3.gif

But now it's the problem, I want to put the watermark (the gif transparent image ) in the bottom of the image, but all didn't work.

I tried compose, covert, draw, but I don't know to extract layers and compose again in batch mode, I need to make it in the all images.

Could someone help me with this?

Thanks,
Tiago

Re: watermark on gif animation

Posted: 2007-10-21T14:14:41-07:00
by sevasjack
You can use either

Code: Select all

convert $imagepath -gravity SouthEast -draw "Image Over 0,0 0,0 $watermark" $imagepath
OR

Code: Select all

composite -dissolve 15 -tile $watermark $imagepath $imagepath
And yea, for animated gif's you should use "coalesce"!

Re: watermark on gif animation

Posted: 2007-10-21T17:14:21-07:00
by anthony
Draw is one way, but another is to use "-layers composite"

I actually did work for a web site (they actually payed me money) to write a script that does exactly what you were requesting. This script predated the '-layers' method too. Sorry, I can't give out that actual script :( But then I could not make some serious improvements for it too.

Essentially it did the task by coalescing, creating that extra space, drawing the watermark and re-optimizing the image. So you are on the right track. keep it up. You will be proud of yourself when you succeed.

Basically you are asking for trouble and I would study completely all four IM Examples pages on animation and video handling before proceeding. You need to really understand the GIF format, its limitations, handling, disposal, and optimization issues, if you are going to get good results for any GIF animation.

Of course if you are only doing this for one or a dozen animations (I doubt this) you can just tweek things until you are happy with the result.

You may however need to consider as few points.
If the animation has no transparency, DON'T ADD TRANSPARENCY, figure out if you should use a specific color background as appropriate.
Second watch the number of added colors, GIF is not known for having a lot of colors and adding extra colors like white, can cause speckling problems. (See E-Dither Pixel Speckling.
Third, adding a banner under an animation will not protect the image. IM can simply strip it. I have done so many times. The best method has been to create a smaller, non-transparent version with a see-though water mark over the animation, as well as have the clearly visible banner underneath. Even if they get by the banner and the watermark, the animation will not be a good as what a paying user could get.
And lastly, watch your GIF optimizaer. Im is pretty good, but sometimes it is better to optimize the animation using multiple methods and programs to see what is best. make sure however that the non-IM optimizer did not destroy the final animated form. Both gifsicle and intergif have crapped out on me for some specific types of animation.

ASIDE: Don't keep crap animations. A lot of GIF animation web sites have tens of thousands of GIF animations, 90% of which is CRAP. People should not have to wade though CRAP to find the gem they are seeking.

It is also better to have one representative animation for set of animations, rather than a pages of slightly different colored animations, if creating a library of animations. This takes administion work, but it is what makes a good GIF animation site.

OKAY I am ranting. but then I have the right to rant, with the various experiences I have had.

Re: watermark on gif animation

Posted: 2007-10-21T20:40:27-07:00
by tiaggo
Hi sevasjack,

these codes don't work..
convert $imagepath -gravity SouthEast -draw "Image Over 0,0 0,0 $watermark" $imagepath
only write watermark in the first frame.. and..
composite -dissolve 15 -tile $watermark $imagepath $imagepath
nothing happens..

Re: watermark on gif animation

Posted: 2007-10-21T22:04:31-07:00
by anthony
For the third time. In convert you need to Coalesce the animation first!!!!!

See IM Examples, http://imagemagick.org/Usage/anim_mods/#draw

Composite will not handle a multi-image animation!

Re: watermark on gif animation

Posted: 2007-10-21T22:15:32-07:00
by sevasjack
tiaggo, yes sorry, use following as said Antony

Code: Select all

convert -coalesce $imagepath -gravity SouthEast -draw "Image Over 0,0 0,0 $watermark" $imagepath
anthony, what do you mean crap animation? Can you show samples? And thanks a lot for your explanations! They are really useful.

Re: watermark on gif animation

Posted: 2007-10-21T23:16:30-07:00
by anthony
Almost but no cigar... read the image BEFORE operating on it.
Coalese is an operator.

Also as mentioned, a better way is to use the -layers composite to overlay images, weather it is one image (overlay animation with image, or static background with animation), or a sequence of images (animation with animation), it will even handle two static images. You can offset using the animation virtual canvas offset, or a gravity effected geometry offset.

Basically I designed it to be as globally useful as I can make it.

Code: Select all

convert $animation  -coalesce  -gravity SouthEast  -geometry +5+5 \
            null: $watermark  -layers composite  \
            -layers optimize $watermarked_animation
Note the overlay can be a PNG with semi-transparent pixels, if you want to make it a more subtle effect. See examples of such watermarking overlays in IM Examples, Annotation.

Re: watermark on gif animation

Posted: 2007-10-22T06:30:09-07:00
by tiaggo
Hey anthony,

This code works:
convert $animation -coalesce -gravity SouthEast -geometry +5+5 \
null: $watermark -layers composite \
-layers optimize $watermarked_animation
Very, very, very thanks, I will make some adjustments.. and I think all will be ok
Tiago

Re: watermark on gif animation

Posted: 2007-11-01T11:11:09-07:00
by omar1
I'm able to use this command from shell without a problem but I get an error within php using a command like this:

Code: Select all

<?
system("exec 2>&1; /usr/local/bin/convert test.gif -coalesce -gravity SouthEast -geometry +5+5 null: watermark.gif -layers /usr/local/bin/composite -layers optimize animation.gif");
?>

convert: UnrecognizedLayerMethod `/usr/local/bin/composite'

The command works perfectly from shell is there something I am missing here? This is using the latest version of Imagemagick on PHP 4.3.9

Re: watermark on gif animation

Posted: 2007-11-01T11:33:01-07:00
by omar1
UPDATE: got it sorted out it was a dumb security permission on the directory.