require 'RMagick'
include Magick
images = ImageList.new("sf.jpg")
images.rows.times { |py|
line = images.get_pixels(0, py, images.columns, 1)
line.size().times { |px|
if (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
}
images.store_pixels(0, py, images.columns, 1, line)
}
images.write("sample1149a.png")
exit
元画像(sf.jpg)
出力画像(sample1149a.png)
動作環境
ruby1.8.6, rmagick2.9.0
No comments:
Post a Comment