Centering / Scaling images in 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
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Centering / Scaling images in animation

Post by dognose »

I'm trying to animate a few images of different sizes and orientations.

Say 100x50, 50x100, 30x30

I'm looking for an easy way to have them animate nicely, with images centered and scaled.

Do I have to individually calculate the offset and resizes? or can I apply something like -gravity center.

as it is now, anything bigger than the first frame gets cut off, and non of the images are scaled or aligned.

Any ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Centering / Scaling images in animation

Post by fmw42 »

what is your command line?

you probably need to use -page as per http://www.imagemagick.org/Usage/anim_basics/

but Anthony is the expert on this

Alternately, just -exent each image to the size of the largest before making the animation

convert image1 image2 image3 ... -background white -gravity center -extent WidthxHeight animation.gif
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Centering / Scaling images in animation

Post by anthony »

I would need to know exactly what you want, you are not clear in what your input and output will be!

Do you have individual images, or a pre-existing GIF animation.

Do you want to scale the images to best fit the size given, or crop them?

But essentially if you create the sequence of frames as what you want to see, then -layers optimize them, you will get an appropriate GIF animation. If the input is already a GIF animation 'coalesce' the animation first so as to remove any existing GIF animation optimizations that could cause problems with your image manipulation.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: Centering / Scaling images in animation

Post by dognose »

Ah, thanks, the -extent option was what I needed. gravity wasn't affecting anything otherwise.

thanks for all your help!
Post Reply