2
下面的ImageMagick命令將裁剪子畫面圖像分成幾個圖像平分:RMagick - 如何將網格圖像裁剪成圖像數組?
convert image.png -crop [email protected] +repage +adjoin tile-%d.jpg
熱辦這跟Rmagick?但不是創建多個文件,我需要返回一組圖像。
下面的ImageMagick命令將裁剪子畫面圖像分成幾個圖像平分:RMagick - 如何將網格圖像裁剪成圖像數組?
convert image.png -crop [email protected] +repage +adjoin tile-%d.jpg
熱辦這跟Rmagick?但不是創建多個文件,我需要返回一組圖像。
設法得到它通過一次croping每個圖像做:
def split_images
#'image' is a ImageMagick Object
width = image.cols/number_cols
height = image.rows/nubmer_rows
images = []
0.upto(number_rows-1) do |x|
0.upto(number_cols-1) do |y|
images << image.crop(Magick::NorthWestGravity, x*width, y*height, width, height, true)
end
end
end