Thursday, February 08, 2007

ImageMagickで回転・縮小するアニメーションGIFを生成する

ImageMagickで回転・縮小するアニメーションGIFを作成するには、
-affineでアフィン変換を使用して回転・スケーリングを行います。
縮小の後、画像サイズが変わるので、-extent及びgravityオプションで
均一サイズにしています。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.1-Q16
rem sx=s*cos(r)
rem rx=s*sin(r)
rem ry=s*-sin(r)
rem sy=s*cos(r)
rem r=30,s=0.95
%im%\convert.exe sample2.png -affine 0.82,0.48,-0.48,0.82,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f2.gif
rem r=60,s=0.90
%im%\convert.exe sample2.png -affine 0.45,0.78,-0.78,0.45,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f3.gif
rem r=90,s=0.85
%im%\convert.exe sample2.png -affine 0.00,0.85,-0.85,0.00,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f4.gif
rem r=120,s=0.8
%im%\convert.exe sample2.png -affine -0.40,0.69,-0.69,-0.40,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f5.gif
rem r=150,s=0.75
%im%\convert.exe sample2.png -affine -0.65,0.38,-0.38,-0.65,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f6.gif
rem r=180,s=0.7
%im%\convert.exe sample2.png -affine -0.70,0.00,0.00,-0.70,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f7.gif
rem r=210,s=0.65
%im%\convert.exe sample2.png -affine -0.56,-0.33,0.33,-0.56,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f8.gif
rem r=240,s=0.55
%im%\convert.exe sample2.png -affine -0.28,-0.48,0.48,-0.28,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f9.gif
rem r=270,s=0.45
%im%\convert.exe sample2.png -affine 0.00,-0.45,0.45,0.00,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f10.gif
rem r=300,s=0.35
%im%\convert.exe sample2.png -affine 0.18,-0.30,0.30,0.18,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f11.gif
rem r=330,s=0.25
%im%\convert.exe sample2.png -affine 0.22,-0.13,0.13,0.22,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f12.gif
rem r=360,s=0.15
%im%\convert.exe sample2.png -affine 0.15,0.00,0.00,0.15,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f13.gif
rem r=390,s=0.05
%im%\convert.exe sample2.png -affine 0.04,0.02,-0.02,0.04,0,0 -transform +repage -gravity center -background white -extent 100x100 -flatten f14.gif
%im%\convert.exe sample2.png f2.gif f3.gif f4.gif f5.gif f6.gif f7.gif f8.gif f9.gif f10.gif f11.gif f12.gif f13.gif f14.gif -set delay 20 -loop 0 sample71.gif

出力画像(sample71.gif)

No comments:

Post a Comment