# Joining lots of small images into one large image

**URL:** <https://rubytalk.org/t/joining-lots-of-small-images-into-one-large-image/57913>\
**Category:** ruby-talk\
**Created:** [28 March 2010 19:06 UTC](https://rubytalk.org/t/joining-lots-of-small-images-into-one-large-image/57913 "2010-03-28T19:06:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azalar](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@Azalar](https://rubytalk.org/u/Azalar)\
**Post date:** [28 March 2010 19:06 UTC](https://rubytalk.org/t/joining-lots-of-small-images-into-one-large-image/57913/1 "2010-03-28T19:06:09Z")

</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

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Rob\_Biedenharn1](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@Rob\_Biedenharn1](https://rubytalk.org/u/Rob_Biedenharn1)\
**Post date:** [28 March 2010 19:54 UTC](https://rubytalk.org/t/joining-lots-of-small-images-into-one-large-image/57913/2 "2010-03-28T19:54:24Z")

</div>

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

-Rob

Rob Biedenharn [http://agileconsultingllc.com](http://agileconsultingllc.com)  
Rob@AgileConsultingLLC.com

> **···**
>
> On Mar 28, 2010, at 3:06 PM, Azalar --- wrote:
> 
> > 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  
> > --
