require 'RMagick'
include Magick
img1 = ImageList.new("sf.jpg")
img2 = Image.new(img1.columns, img1.rows){
self.background_color = "none"
}
img1.alpha = ActivateAlphaChannel
dr = Draw.new
# 描画色
dr.fill = "white"
# 角丸四角を描画
dr.roundrectangle(0,0,img1.columns-1, img1.rows-1, 20, 20)
dr.draw(img2);
img3 = img1.composite(img2, 0, 0, DstInCompositeOp);
# 影を作成
img3.background_color = "black"
img4 = img3.shadow(5, 5, 3, 0.4)
img5 = img4.composite(img3, 0, 0, OverCompositeOp);
img6 = Image.new(img4.columns, img4.rows){
self.background_color='white'
}
img7 = img6.composite(img5, 0, 0, OverCompositeOp);
img7.write("sample458a.png")
exit
元画像(sf.jpg)
出力画像(sample458a)
動作環境
ruby1.8.6-26/RMagick-2.3.0-ImageMagick-6.4.0-2-Q8
関連項目
RMagickをWindowsで使用するための設定
RMagickで画像を角丸四角に切り取る