sas wrote:How can I automatically center all frames (both vertically and horizontally), without having to manually specify a -page offset for each one?
This can be done without much difficulty if you're using ImageMagick 7. Using "ImageMagick 7.0.2-2 Q16 x64" on Windows 7 64, I would use something like this command...
Code: Select all
magick -delay 50 frames/*.png ^
( -clone 0--1 -layers merge -set option:max_w %[w] -set option:max_h %[h] +delete ) ^
-gravity center -background none -extent %[max_w]x%[max_h] -layers trim-bounds out.gif
First that calls in all your images from the "frames" folder.
Next it clones them all and makes them into a single merged layer containing all the images full width and height.
Then it sets a couple of variables, one for the width of that merged image which will be the size of the widest image in the folder. The second variable is for the height and will be the size of the highest image in the folder.
After it gets those dimensions into variables it deletes that temporary merged image.
Next it sets the "-gravity" setting to "center", and it sets the "-background" to "none".
Now the "-extent" operator uses those two variables we made previously to place each image in the center of a transparent background canvas, the total size being the maximum width and height of the largest source images.
Finish by running your "-layers trim-bounds" operation, although at that point I don't think you actually need it.
Give it the output file name, and all the source images are centered and stacked into a GIF animation.