Combine Thumbnails to One Large Image with RMagick

纵然是瞬间 提交于 2020-01-01 03:04:05

问题


What's the shortest way to combine say 20 256x256 thumbnails into a single large image of 4 rows by 5 columns using RMagick?


回答1:


Assuming all the images are in the current directory and named from 1.jpg to n.jpg and row * col = n.

include Magick
row = NUM_ROWS
col = NUM_COLS
ilg = ImageList.new
1.upto(col) {|x| il = ImageList.new
1.upto(row) {|y| il.push(Image.read((y + (x-1)*col).to_s + ".jpg").first)}
ilg.push(il.append(false))}
ilg.append(true).write("out.jpg")


来源:https://stackoverflow.com/questions/1736944/combine-thumbnails-to-one-large-image-with-rmagick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!