Friday, March 30, 2007

ImageMagickで左上が明るいボタンを作成する

ImageMagickで左上が明るいボタンを作成するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.1-Q16
rem ボタン画像1
%im%\convert.exe -size 100x20 xc:none -fill #fad759 -stroke #ffffff -draw "roundrectangle 0,0 99,19 8,8" ( -size 100x20 xc:#f8f8ffff -channel A -fx "((w-i)/w)*((h-j)/h)*0.6+0.3" ) -composite -stroke none -fill #a0a0a0 -draw "font-size 12 text 32,15 'Search'" ( +clone -background #000000 -shadow 40x2+3+3 ) +swap -background white -mosaic sample117a.gif
rem ボタン画像2
%im%\convert.exe -size 100x20 xc:none -fill #c0c0c0 -stroke #ffffff -draw "roundrectangle 0,0 99,19 8,8" ( -size 100x20 xc:#f8f8ffff -channel A -fx "((w-i)/w)*((h-j)/h)*0.6+0.3" ) -composite -stroke none -fill #707070 -draw "font-size 12 text 32,15 'Search'" ( +clone -background #000000 -shadow 40x2+3+3 ) +swap -background white -mosaic sample117b.gif
rem 2つのボタン画像を連結
%im%\convert.exe sample117a.gif sample117b.gif +append button.gif

出力画像(button.gif)

ImageMagickで鏡面映り込みを作成する - その3

ImageMagickで映りこんだ部分に斜線がはいった
鏡面映り込み画像を作成するには以下のバッチを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.1-Q16
rem 反転&半透明グラデーションをかけて
%im%\convert.exe sample4.jpg -bordercolor #c0c0c0 -border 1x1 -channel A -fx "u!=0?(j/h)*0.6:0" -fx "(i+j)%%5==0?0:p" -flip sample4t.png
rem 縦に連結+傾け
%im%\convert.exe sample4.jpg -bordercolor #c0c0c0 -border 1x1 sample4t.png -append -background none -shear 0x5 -gravity center -extent 220x220 sample115a.png
rem jpgで出力
%im%\convert.exe -size 220x220 xc:black sample115a.png -composite sample115b.jpg

元画像(sample4.jpg)


出力画像(sample115b.jpg)

ImageMagickで、重ねあわせ画像の形に合わせてグラデーションを描画する

重ねあわせ画像の形に合わせて、
2色のグラデーションを描画するには以下のバッチを実行します。
(以下の例では黄色と緑のグラデーションになっています)

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.1-Q16
%im%\convert.exe -size 150x150 xc:#20c332 ( -size 150x150 xc:none -channel RGBA sample2.png -geometry +10+10 +composite -fx "p!=0?#FFFF10:0" -blur 0x15 ) -composite sample2.png -geometry +10+10 -composite sample113a.jpg

元画像(sample2.png)


出力画像(sample113a.jpg)


2008/01/04追記
Ver6.3.7では、以下のバッチファイルを実行します。
rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.7-Q16
%im%\convert.exe -size 150x150 xc:#20c332 ( -size 150x150 xc:none -matte -channel RGBA sample2.png -geometry +10+10 +composite -fx "p!=0?#FFFF10FF:0" -blur 0x15 ) -composite sample2.png -geometry +10+10 -composite sample113a.jpg