require 'RMagick'
include Magick
images = ImageList.new("sf.jpg")
img = images[0]
img.rows.times { |py|
line = img.get_pixels(0, py, img.columns, 1)
line.size().times { |px|
if (px % 2) == 0 or (py % 2) == 0 then
line[px].red = line[px].red/2;
line[px].green = line[px].green/2;
line[px].blue = line[px].blue/2;
end
}
img.store_pixels(0, py, img.columns, 1, line)
}
img.write("sample773a.png")
exit
元画像(sf.jpg)
出力画像(sample773a.png)
動作環境
ruby1.8.6, rmagick2.7.1
関連項目
ImageMagickで網掛けをする
No comments:
Post a Comment