アニメーションGIFをリサイズ。→ convertコマンド(ImageMagick)

アニメーションGIFファイルのサムネイル画像(縮小画像)を作る処理をPHPで書こうとしたが、これがかなり面倒くさい。結果、コマンドラインからImageMagickのconvertコマンドを叩くことにした。

コマンド一発でアニメーションを保持しつつ縮小!すばらし〜♪

そんときに調べたことをメモ。


アニメーションGIFのファイル(source.gif)を縦横50%縮小し、output.gif として出力。

convert source.gif -coalesce -scale 50% -deconstruct output.gif


アニメーションGIFのファイル(source.gif)を縦横250pxに収まるようにし、output.gif として出力。

convert source.gif -coalesce -resize 250x250 -deconstruct output.gif


アニメーションGIFのファイル(source.gif)を横250pxにし(縦は縦横比を保ち)、output.gif として出力。

convert source.gif -coalesce -resize 250x -deconstruct output.gif


アニメーションGIFのファイル(source.gif)を縦250pxにし(横は縦横比を保ち)、output.gif として出力。

convert source.gif -coalesce -resize x250 -deconstruct output.gif