Ruby RMagick-如何将网格图像裁剪成一组图像?
以下imageMagick命令将精灵图像裁剪为等分的多个图像:Ruby RMagick-如何将网格图像裁剪成一组图像?,ruby,imagemagick,rmagick,Ruby,Imagemagick,Rmagick,以下imageMagick命令将精灵图像裁剪为等分的多个图像: convert image.png-裁剪2x3-40-20@+重新分页+相邻平铺-%d.jpg 我该怎么做?但是我不需要创建多个文件,而是需要返回一组图像。通过一次抓取每个图像来实现: def split_images #'image' is a ImageMagick Object width = image.cols/number_cols height = image.rows/nubmer_rows ima
convert image.png-裁剪2x3-40-20@+重新分页+相邻平铺-%d.jpg
我该怎么做?但是我不需要创建多个文件,而是需要返回一组图像。通过一次抓取每个图像来实现:
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
def split_图像
#“image”是ImageMagick对象
宽度=image.cols/number\u cols
高度=image.rows/numer\u行
图像=[]
0.最多(第1行)do | x|
0.最多(1号)do | y|
图像通过一次交叉每个图像来完成:
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
def split_图像
#“image”是ImageMagick对象
宽度=image.cols/number\u cols
高度=image.rows/numer\u行
图像=[]
0.最多(第1行)do | x|
0.最多(1号)do | y|
图像