Resizing, Cropping & Converting a series of Images to Patrol Cycle Animated GIF + adding Watermark

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
funkyavocado
Posts: 3
Joined: 2016-01-22T19:38:48-07:00
Authentication code: 1151

Resizing, Cropping & Converting a series of Images to Patrol Cycle Animated GIF + adding Watermark

Post by funkyavocado »

I have a series of images that I want to convert to an animated gif that plays forwards and backwards. In the process I also want to resize and crop them. I'd like the animated gif to have a watermark.

This is what I have that works great without the watermark:

Code: Select all

convert c:\sourceImages\*.jpg -resize "600x400^" -gravity center -crop 600x400+0+0 +repage -coalesce -duplicate 1,-2-1 -set delay 1 -set dispose previous -layers OptimizePlus -quiet -loop 0 c:\finalImages\final.gif
When I add a watermark, it only appears on 1 frame:

Code: Select all

convert c:\sourceImages\*.jpg -resize "600x400^" -gravity center -crop 600x400+0+0 +repage -draw -coalesce -draw 'image SrcOver 0,0 image.jpg' -duplicate 1,-2-1 -set delay 1 -set dispose previous -layers OptimizePlus -quiet -loop 0 c:\finalImages\final.gif
As a test I tried

Code: Select all

convert c:\sourceImages\*.jpg -resize "600x400^" -gravity center -crop 600x400+0+0 +repage -draw -coalesce -draw "text 100,100 'Works like magick!' " -duplicate 1,-2-1 -set delay 1 -set dispose previous -layers OptimizePlus -quiet -loop 0 c:\finalImages\final.gif
and the text appeared over the whole gif, so I'm stumped as to what to do to get an image to appear as the watermark.
Any help is appreciated.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Resizing, Cropping & Converting a series of Images to Patrol Cycle Animated GIF + adding Watermark

Post by GeeMack »

funkyavocado wrote:I have a series of images that I want to convert to an animated gif that plays forwards and backwards. In the process I also want to resize and crop them. I'd like the animated gif to have a watermark.
I'm using "ImageMagick 6.9.3-1 Q16 x64" on Windows 7 64, so for my test I transposed your backslashes to carets for the escape and continued line character. It should work just the same with your backslashes. So taking your first example pretty much exactly as you wrote it...

Code: Select all

convert c:\sourceImages\*.jpg -resize "600x400^" -gravity center -crop 600x400+0+0 +repage \
   -coalesce -duplicate 1,-2-1 -set delay 1 -set dispose previous -layers OptimizePlus -quiet \
   -loop 0 c:\finalImages\final.gif
... and adding a line between "+repage" and "-coalesce" like this...

Code: Select all

convert c:\sourceImages\*.jpg -resize "600x400^" -gravity center -crop 600x400+0+0 +repage \
   null: \( watermark.jpg -resize 64x64 \) -gravity southeast -geometry +20+20 -layers composite \
   -coalesce -duplicate 1,-2-1 -set delay 1 -set dispose previous -layers OptimizePlus -quiet \
   -loop 0 c:\finalImages\final.gif
I get a slide show with a 64x64 version of watermark.jpg at +20+20 from the bottom right corner on every slide.

The "null:" separates the list of images already in the stack from the list of images (a single image in this case) in the watermark stack.

The "( watermark.jpg -resize 64x64 )" brings the watermark image into the command and sizes it as needed.

The "-gravity southeast" prepares the watermark composite to work from the lower right corner.

The "-geometry +20+20" defines the location for the watermark at 20 pixels up and left from the corner.

The "-layers composite" adds the watermark.jpg to the corner of each JPG.

Then it continues with your original command just as you wrote it.
Last edited by GeeMack on 2016-01-22T23:23:24-07:00, edited 1 time in total.
funkyavocado
Posts: 3
Joined: 2016-01-22T19:38:48-07:00
Authentication code: 1151

Re: Resizing, Cropping & Converting a series of Images to Patrol Cycle Animated GIF + adding Watermark

Post by funkyavocado »

That worked! Thanks so much.
funkyavocado
Posts: 3
Joined: 2016-01-22T19:38:48-07:00
Authentication code: 1151

Re: Resizing, Cropping & Converting a series of Images to Patrol Cycle Animated GIF + adding Watermark

Post by funkyavocado »

I've actually changed this a bit so that the final output is an .mp4. Is there any way to have the patrol cycle repeat say like 5 times for the mp4? The gif loops, so that's not a problem, but I would like to make the mp4 longer by having the cycle repeat a few times. I've tried -duplicate 5, 2-1 but that doesn't seem to work.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Resizing, Cropping & Converting a series of Images to Patrol Cycle Animated GIF + adding Watermark

Post by GeeMack »

funkyavocado wrote:I've tried -duplicate 5, 2-1 but that doesn't seem to work.
Can you post the command you're using?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resizing, Cropping & Converting a series of Images to Patrol Cycle Animated GIF + adding Watermark

Post by fmw42 »

try -duplicate 5,0--1 (you missed the needed extra -). see http://www.imagemagick.org/Usage/basics/#duplicate
Post Reply