Justin Lok
Justin Lok

Reputation: 1270

Batch resizing animated gifs

How do I batch resize animated gifs with imagemagick? I have this script which works for single images but I must specify both the exact image name.

convert {path to image with filename}.gif -coalesce -resize 200x200 \
        -layers optimize-frame {output name}.gif

mogrify -path seems to batch process but animations all come out broken with mogrify.

Upvotes: 1

Views: 514

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207455

You don't say if you are using OS X, Linux or Windows, but if on either of the first two and using bash, you can use a loop:

for f in CurrentLocation/*.gif; do convert "$f" -coalesce -resize... -layers... NewLocation/$(basename "$f"); done

If you are unfortunate enough to have to use Windows, it will look something like this:

FOR %%G IN (SOMEWHERE/*.GIF) DO convert "%%G" -set filename:new "%f" -coalesce -resize... -layers... "elsewhere/%[filename:new]"

Upvotes: 2

Related Questions