批量调整动画gif大小


Batch resizing animated gifs

我如何批量调整动画gif与imagemagick?我有这个脚本,它适用于单个图像,但我必须指定准确的图像名称。

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

mogrify -path似乎是批处理,但动画都是用mogrify出来的。

您没有说明您使用的是OS X, Linux还是Windows,但如果在前两个系统中使用bash,则可以使用循环:

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

如果你很不幸必须使用Windows,它看起来像这样:

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