Monday, April 21, 2008

ImageMagickで、角丸四角のグラデーションにハーフトーンを重ね合わせる

角丸四角のグラデーションにハーフトーンを重ね合わせるには、以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.9-Q16
%im%\convert.exe -size 200x200 xc:none -fill white -draw "roundrectangle 0,0 199,199 15,15" -fx "s.p==0?0:(1-sin(pi*j/h))*0.5" -matte sample364a.png
%im%\convert.exe sample364a.png -ordered-dither h16x16o -blur 0x1 -matte -channel a -fx "p!=0?0.1:0" -channel rgba ( sample364a.png ) -swap 0,1 -composite sample364b.png

上記バッチファイルでは、以下の処理を実行しています。
1. 横200ピクセル、縦200ピクセルのキャンパスサイズで、角丸四角を描画し、上下が明るくなるように-fxで色を変更します。
2. h16x16oのthreshold mapを使用して、ハーフトーンのディザリングを行い、ぼかします(-blur)。
3. ピクセル値が0でないピクセルのalpha値に0.1を設定し、1の出力画像と重ね合わせます。

出力画像(sample364b.png)


関連項目
ImageMagickで上下グラデーションの角丸四角を描画する

No comments: