2012-09-10 45 views

回答

4

設法得到它通過一次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