# Reshape and merge an array of images

**URL:** <https://discourse.julialang.org/t/reshape-and-merge-an-array-of-images/49172>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 28, 2020, 12:25pm UTC](https://discourse.julialang.org/t/reshape-and-merge-an-array-of-images/49172 "2020-10-28T12:25:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 28, 2020, 12:25pm UTC](https://discourse.julialang.org/t/reshape-and-merge-an-array-of-images/49172/1 "2020-10-28T12:25:18Z")

</div>

Hi, I have an array of images and I simply want to merge them into one, efficiently.  
Say that my array has 6 images, I would want to form something like;

```julia
1 2 or 1 2 3
3 4 4 5 6
5 6      

```

At the time I’m doing this with nested loops and it seems unnecessary, there should be an easier way, like `reshape(arr, (2, 3))` and merge them together at the same time.

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [October 28, 2020, 12:39pm UTC](https://discourse.julialang.org/t/reshape-and-merge-an-array-of-images/49172/2 "2020-10-28T12:39:50Z")

</div>

It looks like `hvcat` can be used here: [Concatenating in comprehension - #8 by Skoffer](https://discourse.julialang.org/t/concatenating-in-comprehension/48818/8)

---

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 28, 2020, 12:42pm UTC](https://discourse.julialang.org/t/reshape-and-merge-an-array-of-images/49172/3 "2020-10-28T12:42:12Z")

</div>

Yes!! That was it.

> using TestImages  
> ARR = [testimage(“cameraman”) for i in 1:6];  
> hvcat(3, ARR…)  
> hvcat(2, ARR…)

does the trick.

Thank you so much for your answer.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 29, 2020, 8:21am UTC](https://discourse.julialang.org/t/reshape-and-merge-an-array-of-images/49172/4 "2020-10-29T08:21:52Z")

</div>

If your images are of different sizes, there’s also the [MosaicViews](https://github.com/JuliaArrays/MosaicViews.jl) package.
