Watermarking an animated GIF with varied frame offsets and sizes

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
coloring
Posts: 82
Joined: 2015-08-27T10:17:36-07:00
Authentication code: 1151

Watermarking an animated GIF with varied frame offsets and sizes

Post by coloring »

I'm using ImageMagick 6.9.0-10 Q16 x64 2015-02-28 on Windows 8.1 via the command line.

I want to watermark multiple animated GIFs at once.
The GIFs canvas is always exactly 320px wide, but height wildly varies between 100px and 1200px. GIFs have varied frame sizes and varied offsets.
The watermark is huge and needs to be resized to fit the GIF.

This is what I've done so far:

Code: Select all

mogrify.exe -coalesce -draw "image Over 5,5 184,64 'big_watermark.png'" -layers Optimize *.gif
And it made the watermark jump all over the place (probably due to frame offsets?):
Image

1) How can I overlay the watermark relative to the canvas instead to each individual frame?
2) Is it possible to resize the watermark based on the GIF's height? E.g. larger watermark on larger GIFs and vice versa.

Files:
big_watermark.png: http://i.imgur.com/OZtDB5e.png
source.gif: http://i.imgur.com/OG5YM3C.gif

P.S.: I've managed to solve my first problem with `convert` but I'd love a IM one-liner to batch process all these GIFs with watermark resizing relative to source height.
My solution:

Code: Select all

convert.exe source.gif -coalesce -draw "image Over 5,5 184,64 'big_watermark.png'" -layers Optimize output.gif
Result (working as intended): http://i.imgur.com/OjGd9Ab.gif

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Watermarking an animated GIF with varied frame offsets and sizes

Post by snibgo »

Mogrify has limited capabilities. I would do a single convert (or v7 magick) for each GIF, and run that inside a shell "for" loop.
coloring wrote:2) Is it possible to resize the watermark based on the GIF's height? E.g. larger watermark on larger GIFs and vice versa.
Sure. For example, you might want to make the watermark 20% of the GIF width and 10% of the GIF height. In v6, I would do that with a shell script: an identify command gets the dimensions and calculates the required size, then the convert resizes the watermark and composites it. In v7, it can be done in a single convert command.
snibgo's IM pages: im.snibgo.com
coloring
Posts: 82
Joined: 2015-08-27T10:17:36-07:00
Authentication code: 1151

Re: Watermarking an animated GIF with varied frame offsets and sizes

Post by coloring »

OK. Thanks for the tips.
I'll go the v6 + shell route for now, due to familiarity and time restraints.
I will have to look into v7, though, it looks nice!
Post Reply