# Joining lots of small images into one large image

**URL:** <https://www.ruby-forum.com/t/joining-lots-of-small-images-into-one-large-image/185898>\
**Category:** Ruby\
**Created:** [March 28, 2010, 9:06pm UTC](https://www.ruby-forum.com/t/joining-lots-of-small-images-into-one-large-image/185898 "2010-03-28T21:06:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![azalar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e0b2c6/32.png) [@azalar](https://www.ruby-forum.com/u/azalar)\
**Post date:** [March 28, 2010, 9:06pm UTC](https://www.ruby-forum.com/t/joining-lots-of-small-images-into-one-large-image/185898/1 "2010-03-28T21:06:05Z")

</div>

I have 40 small images that are 70 x 70 pixels and they are numbered  
like 1.jpg, 2.jpg etc up to 40.jpg

I want to merge these into 1 large image strip 2800 x 70 pixels in Ruby  
code but am not sure of the best approach to this.

Can anyone point me in the right direction for this or better still a  
snippet of code?

Thanks

Az

---

<div class="post-metadata">

**Author:** ![azalar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e0b2c6/32.png) [@azalar](https://www.ruby-forum.com/u/azalar)\
**Post date:** [March 28, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/joining-lots-of-small-images-into-one-large-image/185898/2 "2010-03-28T21:54:47Z")

</div>

On Mar 28, 2010, at 3:06 PM, Azalar — wrote:

> Thanks
> 
> ## Az

That’s exactly what the ‘montage’ command from ImageMagick does. As  
long as  
using:  
images = (1…40).map{|i| “#{i}.jpg”}  
system(“montage #{images.join(’ ')} +page -tile 40x1 -geometry  
70x70+0+0 #{outfile}”)  
counts as “Ruby code”, then you’re all set!

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
