次のimageMagickコマンドは、スプライト画像を均等に分割された複数の画像にトリミングします。
convert image.png -crop 2x3-40-20@ +repage +adjoin tile-%d.jpg
ホット私はRmagickでこれを行いますか?しかし、複数のファイルを作成する代わりに、画像の配列を返す必要があります。
次のimageMagickコマンドは、スプライト画像を均等に分割された複数の画像にトリミングします。
convert image.png -crop 2x3-40-20@ +repage +adjoin tile-%d.jpg
ホット私はRmagickでこれを行いますか?しかし、複数のファイルを作成する代わりに、画像の配列を返す必要があります。
一度に各画像をトリミングすることで、それを成し遂げることができました。
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