require 'RMagick'
include Magick
images = ImageList.new("sf.jpg")
images.alpha = ActivateAlphaChannel
images2 = ImageList.new
images2.new_image(20, 20){
self.background_color = "none"
}
dr = Draw.new
dr.fill = "white"
dr.roundrectangle(0,0,18,18,4,4);
dr.draw(images2)
images3 = ImageList.new()
images3.new_image(images.columns, images.rows,
TextureFill.new(images2))
images3.alpha = ActivateAlphaChannel
images.composite(images3, CenterGravity, 0, 0,
DstInCompositeOp).write("sample1147a.png")
exit
元画像(sf.jpg)
出力画像
動作環境
ruby1.8.6, rmagick2.9.0
関連項目
ImageMagickで画像を角丸四角タイルパターンで切り取る (convertコマンドでの同様の処理)
No comments:
Post a Comment