Monday, May 04, 2009

ScriptomとImageMagickで画像と半透明グラデーションを重ねる

ScriptomとImageMagickで画像と半透明グラデーションを重ねるには、以下のコードを実行します。

import org.codehaus.groovy.scriptom.*

Scriptom.inApartment
{
im = new ActiveXObject("ImageMagickObject.MagickImage.1")
width = im.identify("-format", "%w", "sf2.jpg")
height = im.identify("-format", "%h", "sf2.jpg")
im.convert("sf2.jpg", "-size", "${width}x${height}",
"gradient:#ffffffff-#00000000",
"-composite", "sample1074a.png")
}

元画像(sf2.jpg)


出力画像(sample1074a.png)



動作環境
Groovy1.6.0, JDK1.6 Update12, ImageMagick6.5.0, Microsoft VC++ 2008 Redistributable
※ImageMagickインストール時にCOMインターフェイスも入れておくこと。

関連項目
ImageMagickで霧がかかったような効果

No comments: