Friday, May 25, 2007

ImageMagickでカーブした光沢のある文字列を描画する

ImageMagickでカーブした光沢のある文字列を描画するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.4-Q16
%im%\convert.exe -size 300x80 xc:none -stroke #f8c749 -fill #f8c749 -gravity center -font Tahoma -draw "font-size 50 text 0,0 'ImageMagick'" -fx "(sin(i/w*pi)*h*0.2+h*0.4)>j?#FEF779:p" sample163a.png

出力画像(sample163a.png)



凸形状に光沢をつけるには、以下のコマンドを実行します。
%im%\convert.exe -size 300x80 xc:none -stroke #f8c749 -fill #f8c749 -gravity center -font Tahoma -draw "font-size 50 text 0,0 'ImageMagick'" -fx "(h*0.2-sin(i/w*pi)*h*0.2+h*0.5)>j?#FEF779:p" sample163b.png

出力画像(sample163b.jpg)


関連項目

ImageMagickで右方向へだんだんと白黒画像になっていくグラデーションを作成する

ImageMagickで右方向へだんだんと白黒画像になっていくグラデーションを作成するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.4-Q16
%im%\convert.exe sample10.jpg -channel A -fx "i<(w/3)?1:((w-w/3)-(i-w/3))/(w-w/3)" t1.png %im%\convert.exe sample10.jpg -fx "(r+g+b)/3" t1.png -composite sample162.jpg

上記バッチファイルでは、画像幅の1/3から徐々に白黒画像になっていきます。

元画像(sample10.jpg)



出力画像(sample162.jpg)


2008/01/04追加
ver6.3.7では、以下のバッチファイルのように-channelの前に-matteを追加します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.7-Q16
%im%\convert.exe sample10.jpg -matte -channel A -fx "i<(w/3)?1:((w-w/3)-(i-w/3))/(w-w/3)" t1.png
%im%\convert.exe sample10.jpg -fx "(r+g+b)/3" t1.png -composite sample162.jpg
rem 上記と同様の処理を1回の実行で行う
%im%\convert.exe sample10.jpg -fx "(r+g+b)/3" ( sample10.jpg -matte -channel A -fx "i<(w/3)?1:((w-w/3)-(i-w/3))/(w-w/3)" ) -composite sample162b.jpg

関連項目
ImageMagickでだんだんと白黒画像になっていくグラデーションを作成する

Wednesday, May 23, 2007

ImageMagickで画像に影付けして複数方向にモーションブラーをかける

ImageMagickで画像に影付けして複数方向にモーションブラーをかけるには、
以下のバッチを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.4-Q16
%im%\convert.exe -size 150x150 xc:#ffffff ( sample2.png -background none -gravity center -extent 150x150 ) ( +clone -background #bbddff -shadow 80x2+0+0 -motion-blur 0x20+225 ) +swap ( +clone -background #bbddff -shadow 80x2+3+3 -motion-blur 0x20+105 ) +swap ( +clone -background #bbddff -shadow 80x2+3+3 -motion-blur 0x20+345 ) +swap -mosaic sample161a.jpg

上記のバッチでは、225度、105度、345度にモーションブラーをかけています。

元画像(sample2.png)


出力画像(sample161a.jpg)

Saturday, May 19, 2007

ImageMagickで透過PNGのエッジ抽出画像を生成する

ImageMagickで透過PNGのエッジ抽出画像を生成するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.4-Q16
%im%\convert.exe sample9b.jpg -enhance -enhance -enhance -enhance -enhance -edge 2 -threshold 50%% -channel A -fx "p.r==1?1:0" -channel RGB -fx "p==1?#2050C0:0" -channel RGBA -blur 1 sample160.png
%im%\convert.exe sample9b.jpg -fx "(r+g+b)/3" sample160.png -composite sample160b.png

元画像(sample9b.jpg)


出力画像(sample160.png)


白黒画像と重ねあわせた例(sample160b.png)

ImageMagickでだんだんと白黒画像になっていくグラデーションを作成する

ImageMagickでだんだんと白黒画像になっていくグラデーションを作成するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.4-Q16
%im%\convert.exe sample10.jpg -channel A -fx "1-sqrt(pow(150-i,2)+pow(50-j,2))/100" t1.png
%im%\convert.exe sample10.jpg -fx "(r+g+b)/3" t1.png -composite sample159.jpg

上記のバッチでは、座標(150,50)から遠ざかるほどに白黒画像になります。

元画像(sample10.jpg)


出力画像(sample159.jpg)

ImageMagickで一部分だけ焦点のあっている画像に処理する

ImageMagickで一部分だけ焦点のあっている画像に処理するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.4-Q16
%im%\convert.exe -size 200x100 xc:none -fill white -draw "ellipse 50,50 40,40 0,360" sample8.jpg -compose srcin -composite p1.png
%im%\convert.exe -size 200x100 xc:none -fill white -draw "ellipse 50,50 45,45 0,360" sample8.jpg -compose srcin -composite -channel RGBA -blur 0x1 p2.png
%im%\convert.exe -size 200x100 xc:none -fill white -draw "ellipse 50,50 55,55 0,360" sample8.jpg -compose srcin -composite -channel RGBA -blur 0x2 p3.png
%im%\convert.exe -size 200x100 xc:none -fill white -draw "ellipse 50,50 70,70 0,360" sample8.jpg -compose srcin -composite -channel RGBA -blur 0x3 p4.png
%im%\convert.exe sample8.jpg -blur 0x4 p4.png p3.png p2.png p1.png -flatten sample158.png

上記のバッチでは、座標(50,50)を中心とした同心円をそれぞれ切り抜き、ぼかしを外側に向かって
強くかけるようにしています。

元画像(sample8.jpg)


出力画像(sample158.png)

ImageMagickで画像の上下を半透明グラデーションにする

ImageMagickで画像の上下を半透明グラデーションにするには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.4-Q16
%im%\convert.exe sample3b.jpg -channel A -fx "abs(sin(pi*j/h))" sample157a.png
%im%\convert.exe -size 150x150 pattern:checkerboard -gravity center sample157a.png -composite sample157b.jpg

元画像(sample3b.jpg)


出力画像(sample157a.png)


重ねあわせ例(sample157b.jpg)


2008/01/04追記
ver6.3.7では、以下のバッチファイルのように-channelの前に-matteを追加します。
rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.7-Q16
%im%\convert.exe sample3b.jpg -matte -channel A -fx "abs(sin(pi*j/h))" sample157a.png
%im%\convert.exe -size 150x150 pattern:checkerboard -gravity center sample157a.png -composite sample157b.jpg

関連項目
ImageMagickで上下・左右に半透明グラデーションをかける

Friday, May 11, 2007

ImageMagickとVBS(WSH)でポラロイド写真を並べた画像を生成する

ImageMagickとVBS(WSH)でポラロイド写真を並べた画像を生成するには、
以下のpolaroids.vbsを実行します。

cscript polaroids.vbs sample156.jpg sample3b.jpg sample4.jpg sample5.jpg sample6.jpg sample9b.jpg
polaroids.vbs
----------------------------------------------------------------------------

Set im = CreateObject("ImageMagickObject.MagickImage.1")
pi=3.14159
rem 開始角
sa=-30
rem 終了角
ea=30
rem 半径
rad=150
rem 出力サイズx
ox=300
oy=200

da=abs(sa-ea)/(WScript.Arguments.Count-2)
WScript.StdOut.WriteLine da
ra = sa
ofile = WScript.Arguments(0)


im.Convert "-size", ox & "x" & oy, "gradient:#ffffff-#bbddff", ofile
For wl=1 to WScript.Arguments.Count -1
infile = WScript.Arguments(wl)
outfile = WScript.Arguments(wl) & ".png"
WScript.StdOut.WriteLine "infile:" & infile
WScript.StdOut.WriteLine "outfile:" & outfile
WScript.StdOut.WriteLine "ra:" & ra
im.Convert infile, "-background", "none", "-polaroid", ra, "+repage", outfile

gx = int(rad * cos(2*pi*(ra+270)/360))
gy = int(rad * sin(2*pi*(ra+270)/360))
width = im.identify("-format", "%w", outfile)
height = im.identify("-format", "%h", outfile)
WScript.StdOut.WriteLine "width:" & width
agx = gx -width/2 +ox/2
agy = gy -height/3 +oy
if agx > 0 then sgx = "+" & agx else sgx = "" & agx end if
if agy > 0 then sgy = "+" & agy else sgy = "" & agy end if

im.Convert ofile, outfile, "-geometry", sgx & sgy, "-composite", ofile


ra=ra+da
Next
Set im = Nothing
----------------------------------------------------------------------------

出力画像(sample156.jpg)


関連項目
ImageMagickとWSHで、バッジ画像を生成する
ImageMagickで、画像をポラロイド写真風にして、日本語文字列を描画する

ImageMagickで画像を傾けて影付けする

ImageMagickで画像を傾けて影付けするには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16

%im%\convert.exe sample8.jpg -bordercolor #c0b49d -border 3 -resize 150x75 -background none -rotate 7 ( +clone -background #000000 -shadow 150x3+3+3 ) +swap -background none -mosaic sample155a.png
%im%\convert.exe -size 200x100 gradient:#f4a729-#fce769 sample155a.png -geometry +40+25 -composite sample155b.png

元画像(sample8.jpg)


出力画像(sample155b.png)

Thursday, May 10, 2007

ImageMagickでカーブがかかったグラデーションを描画する

ImageMagickでカーブがかかったグラデーションを描画するには、
以下のバッチを実行します。
rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 200x50 xc:white ( -size 200x50 gradient:#7799cc-#bbddff ) -append -wave 10x400 -gravity center -crop 200x50+0+0 +repage sample154a.png
出力画像(sample154a.png)

%im%\convert.exe -size 200x50 xc:white ( -size 200x50 gradient:#f4a729-#fce769 ) -append -wave -10x400 -gravity center -crop 200x50+0+0 +repage sample154b.png


出力画像(sample154b.png)

Saturday, May 05, 2007

ImageMagickで枠が立体的な凹み角丸四角のプレートを描画する

ImageMagickで枠が立体的な凹み角丸四角のプレートを描画するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 200x50 xc:none -stroke #f8c749 -fill none -draw "stroke-width 3 path 'M 10,1 A 10,10 0 0,1 1,10 L 1,39 A 10,10 0 0,1 9,48 L 189,48 A 10,10 0 0,1 198,39 L 198,10 A 10,10 0 0,1 189,1 Z" sample153a.png
%im%\convert.exe sample153a.png -background none -gravity center -extent 202x52 -threshold 1 -shade 135x20 -blur 0x1 -normalize sample153a.png -compose overlay -composite -gravity center -crop 200x50+0+0 +repage sample153b.png
%im%\convert.exe -size 200x50 xc:none -stroke #f8c749 -tile gradient:#fce769-#ffffee -draw "stroke-width 3 path 'M 10,1 A 10,10 0 0,1 1,10 L 1,39 A 10,10 0 0,1 9,48 L 189,48 A 10,10 0 0,1 198,39 L 198,10 A 10,10 0 0,1 189,1 Z" sample153b.png -composite sample153c.png

出力画像(sample153c.png)

ImageMagickで凹み角丸四角を描画する

ImageMagickで凹み角丸四角を描画するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 200x50 xc:none -stroke #f8c749 -fill #ffffee -draw "path 'M 10,0 A 10,10 0 0,1 0,10 L 0,39 A 10,10 0 0,1 9,49 L 189,49 A 10,10 0 0,1 199,39 L 199,10 A 10,10 0 0,1 189,0 Z" sample152a.png

出力画像(sample152a.png)

Thursday, May 03, 2007

ImageMagickで2色ストライプの円を描画する

ImageMagickで2色ストライプの円を描画するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 400x200 xc:none -tile gradient:#ffffff-#bbddff -draw "path 'M 200,200 L 200,0 A 200,200 0 0,1 252,6 Z" -tile gradient:#ffffff-#ffeebb -draw "path 'M 200,200 L 147,6 A 200,200 0 0,1 200,0 Z" sample151a.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 30 -gravity center -crop 400x400+0+0 +repage r1.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 60 -gravity center -crop 400x400+0+0 +repage r2.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 90 -gravity center -crop 400x400+0+0 +repage r3.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 120 -gravity center -crop 400x400+0+0 +repage r4.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 150 -gravity center -crop 400x400+0+0 +repage r5.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 180 -gravity center -crop 400x400+0+0 +repage r6.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 210 -gravity center -crop 400x400+0+0 +repage r7.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 240 -gravity center -crop 400x400+0+0 +repage r8.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 270 -gravity center -crop 400x400+0+0 +repage r9.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 300 -gravity center -crop 400x400+0+0 +repage r10.png
%im%\convert.exe sample151a.png -background none -extent 400x400 -rotate 330 -gravity center -crop 400x400+0+0 +repage r11.png
%im%\convert.exe sample151a.png r1.png r2.png r3.png r4.png r5.png r6.png r7.png r8.png r9.png r10.png r11.png -mosaic -resize 200x200 sample151b.png

出力画像(sample151b.png)

Wednesday, May 02, 2007

ImageMagickで半透明矩形に透過文字を描画して影付けする

ImageMagickで半透明矩形に透過文字を描画して影付けするには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 100x50 xc:#00000080 -channel RGBA -fill #000000ff +antialias -gravity center -draw "font-size 18 text 0,0 'Flower'" -fx "p==#000000?0:p" sample149a.png
%im%\convert.exe sample7.jpg ( sample149a.png -background none -gravity center -extent 150x100 ) ( +clone -background #BBDDFF -shadow 150x3+3+3 ) +swap -mosaic sample149b.jpg

元画像(sample7.jpg)


出力画像(sample149b.jpg)


2008/01/04追記
ver6.3.7では、以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.7-Q16
%im%\convert.exe -matte -channel RGBA -size 100x50 xc:#00000080 -fill #000000ff +antialias -gravity center -draw "font-size 18 text 0,0 'Flower'" -fx "p==#000000FF?0:p" sample149a.png
%im%\convert.exe sample7.jpg ( sample149a.png -background none -gravity center -extent 150x100 ) ( +clone -background #BBDDFF -shadow 150x3+3+3 ) +swap -mosaic -crop 150x100+0+0 sample149b.jpg

Sunday, April 29, 2007

ImageMagickで画像に影付けしてモーションブラーをかける

ImageMagickで画像(透過PNG)に影付けしてモーションブラーをかけるには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 150x150 xc:white ( sample2.png -background none -gravity center -extent 150x150 ) ( +clone -background #000000 -shadow 40x2+3+3 -motion-blur 0x20+225 ) +swap -mosaic sample148a.jpg

元画像(sample2.png)


出力画像(sample148a.jpg)


関連項目
ImageMagickとPHPで透過PNGに影付けして、影にモーションブラーをかける
ImageMagickとPHPで、文字列にモーションブラーをかける

Tuesday, April 24, 2007

ImageMagickで画像の2値化切り取りと重ねあわせ処理する

ImageMagickで画像の2値化切り取りと重ねあわせ処理するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe sample5b.jpg -threshold 53000 -negate -channel A -fx p.r==1?1:0 sample147a.png
%im%\convert.exe sample147a.png -fx "p==1?#909F90:0" bg1.png
%im%\convert.exe sample147a.png -fx "p==1?#B0BFB0:0" bg2.png
%im%\convert.exe sample147a.png -fx "p==1?#D0DFD0:0" bg3.png
%im%\convert.exe sample147a.png -fx "p==1?#F0FFF0:0" bg4.png
%im%\convert.exe sample147a.png sample5b.jpg -compose src_in -composite sample147b.png
%im%\convert.exe -size 100x100 xc:white bg4.png -composite bg3.png -geometry -20+24 -composite bg2.png -geometry -10+16 -composite bg1.png -geometry +0+8 -composite sample147b.png -geometry +10+0 -composite sample147.jpg

元画像(sample5b.jpg)


出力画像(sample147.jpg)

Sunday, April 22, 2007

ImageMagickで画像に立体的な枠をつける

ImageMagickで画像に立体的な枠をつけるには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 100x100 xc:none -channel RGBA -fill white -draw "roundrectangle 5,5 94,94 10,10" sample8.jpg -compose src_in -composite sample141a.png
%im%\convert.exe -size 100x100 xc:none -fill none -stroke white -strokewidth 6 -draw "roundrectangle 5,5 94,94 10,10" -shade 135x25 -blur 0x1 -normalize sample141a.png -compose overlay -composite sample141b.png

元画像(sample8.jpg)


出力画像(sample141b.jpg)

Saturday, April 21, 2007

ImageMagickで任意の2色の上下グラデーションの角丸四角を描画する

ImageMagickで任意の2色の上下グラデーションの角丸四角を描画するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
%im%\convert.exe -size 150x150 xc:none -fill white -draw "roundrectangle 0,0 149,149 15,15" ( xc:#e0ff80 xc:#80ffff +append -resize 2x1 ) -fx "s.p==0?0:v.p{(1-sin(pi*j/h)),1}" -matte sample150a.gif

出力画像(sample150a.gif)

関連項目

ImageMagickで彩度が変化するGIFアニメーションを作成する

ImageMagickで彩度が変化するGIFアニメーションを作成するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
rem 彩度を変更(明るさはそのまま)
%im%\convert.exe sample4.jpg -modulate 100,100 f1.png
%im%\convert.exe sample4.jpg -modulate 100,90 f2.png
%im%\convert.exe sample4.jpg -modulate 100,80 f3.png
%im%\convert.exe sample4.jpg -modulate 100,70 f4.png
%im%\convert.exe sample4.jpg -modulate 100,60 f5.png
%im%\convert.exe sample4.jpg -modulate 100,50 f6.png
%im%\convert.exe sample4.jpg -modulate 100,40 f7.png
%im%\convert.exe sample4.jpg -modulate 100,30 f8.png
%im%\convert.exe sample4.jpg -modulate 100,20 f9.png
%im%\convert.exe sample4.jpg -modulate 100,10 f10.png
%im%\convert.exe sample4.jpg -modulate 100,0 f11.png

%im%\convert.exe f1.png f2.png f3.png f4.png f5.png f6.png f7.png f8.png f9.png f10.png f11.png -set delay 20 -loop 0 sample146.gif

元画像(sample4.jpg)


出力画像(sample146.gif)

Friday, April 20, 2007

ImageMagickで画像を銭湯タイル風に変換する

ImageMagickで画像を銭湯タイル風に変換するには、
以下のバッチファイルを実行します。

rem 環境によって変えてね
set im=C:\Progra~1\ImageMagick-6.3.3-Q16
rem モザイク画像の生成と縦線描画
%im%\convert.exe -size 100x100 xc:none -channel RGBA ( sample4.jpg -resize 10x10 ) -fx "i%%10<9?v.p{ceil((i+1)/10)-1,ceil((j+1)/10)-1}:0" sample143a.png
rem 横格子線のついたモザイク画像の生成
%im%\convert.exe sample143a.png -channel RGBA -fx "j%%10<9?p:0" sample143b.png
rem 立体化してタイル風に。
%im%\convert.exe sample143b.png -threshold 1 -shade 135x20 -blur 0x1 -normalize sample143b.png -compose overlay -composite sample143c.png

元画像(sample4.jpg)


出力画像(sample143b.png)


出力画像(sample143c.png)