require 'RMagick'
include Magick
# 画像の任意の矩形領域の境界をぼかしてその領域以外を暗くする
# 余白
padx = 20
pady = 20
images = ImageList.new("sf.jpg")
images.alpha = ActivateAlphaChannel
img2 = Image.new(images.columns, images.rows){
self.background_color = "none"
}
dr = Draw.new
dr.fill = "blue"
dr.rectangle(padx,pady,images.columns-padx-1,images.rows-pady-1)
dr.draw(img2)
img2 = images.composite(
img2.blur_channel(0,5,AllChannels),
0, 0, DstInCompositeOp);
images = images.quantum_operator(MultiplyQuantumOperator, 0.5,
DefaultChannels).
composite(img2, NorthWestGravity, 0, 0, OverCompositeOp).
write("sample936a.jpg")
exit
元画像(sf.jpg)
出力画像(sample936a.jpg)
動作環境
ruby1.8.6, rmagick2.7.1
No comments:
Post a Comment