---
title: "ImageCollage"
language: "en"
type: "Symbol"
summary: "ImageCollage[{image1, image2, ...}] creates a collage of images imagei. ImageCollage[{w1 -> image1, w2 -> image2, ...}] creates a collage of images imagei based on their corresponding weights wi. ImageCollage[<|image1 -> w1, image2 -> w2, ...|>] also creates a collage of images imagei based on their corresponding weights wi. ImageCollage[{w1, w2, ...} -> {image1, image2, ...}] also creates a collage of images imagei based on their corresponding weights wi. ImageCollage[{{image1, w1}, {image2, w2}, ...}] also creates a collage of images imagei based on their corresponding weights wi. ImageCollage[..., fitting] uses the fitting method to create the collage. ImageCollage[..., fitting, size] creates a collage of the specified size."
keywords: 
- image cloud
- image collage
- collage
- image packing
- image pack
- word cloud
- photo collage
- photo mosaic
- photocollage
- artensoft
- collage maker
canonical_url: "https://reference.wolfram.com/language/ref/ImageCollage.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Image Composition"
    link: "https://reference.wolfram.com/language/guide/ImageComposition.en.md"
  - 
    title: "Data Visualization"
    link: "https://reference.wolfram.com/language/guide/DataVisualization.en.md"
  - 
    title: "Basic Image Manipulation"
    link: "https://reference.wolfram.com/language/guide/BasicImageManipulation.en.md"
  - 
    title: "Computational Photography"
    link: "https://reference.wolfram.com/language/guide/ComputationalPhotography.en.md"
related_workflows: 
  - 
    title: "Combine Multiple Images"
    link: "https://reference.wolfram.com/language/workflow/CombineMultipleImages.en.md"
related_functions: 
  - 
    title: "ImageAssemble"
    link: "https://reference.wolfram.com/language/ref/ImageAssemble.en.md"
  - 
    title: "WordCloud"
    link: "https://reference.wolfram.com/language/ref/WordCloud.en.md"
  - 
    title: "GraphicsGrid"
    link: "https://reference.wolfram.com/language/ref/GraphicsGrid.en.md"
  - 
    title: "ImageCompose"
    link: "https://reference.wolfram.com/language/ref/ImageCompose.en.md"
  - 
    title: "ImageAdd"
    link: "https://reference.wolfram.com/language/ref/ImageAdd.en.md"
  - 
    title: "Blend"
    link: "https://reference.wolfram.com/language/ref/Blend.en.md"
---
# ImageCollage

ImageCollage[{image1, image2, …}] creates a collage of images imagei.

ImageCollage[{w1 -> image1, w2 -> image2, …}] creates a collage of images imagei based on their corresponding weights wi.

ImageCollage[<|image1 -> w1, image2 -> w2, …|>] also creates a collage of images imagei based on their corresponding weights wi.

ImageCollage[{w1, w2, …} -> {image1, image2, …}] also creates a collage of images imagei based on their corresponding weights wi.

ImageCollage[{{image1, w1}, {image2, w2}, …}] also creates a collage of images imagei based on their corresponding weights wi.

ImageCollage[…, fitting] uses the fitting method to create the collage.

ImageCollage[…, fitting, size] creates a collage of the specified size.

## Details and Options

* ``ImageCollage`` creates a collage of a list of images and can be used to create a compact visualization of photographs, graphics, etc.

* ``ImageCollage[w -> {image1, image2, …}]`` assumes the same weight ``w`` for all ``imagei``.

* Weights ``wi`` can be either of one of the following forms:

|           |                                                              |
| --------- | ------------------------------------------------------------ |
| w         | final area proportional to w                                 |
| Scaled[s] | final area proportional to s multiplied by the original area |

* Possible values for ``fitting`` include:

|           |                                                               |
| --------- | ------------------------------------------------------------- |
| "Fill"    | fit the smaller dimension; crop the other if necessary        |
| "Fit"     | fit the whole image; keep the aspect ratio; pad if necessary  |
| "Stretch" | stretch the image to fit by resampling                        |

* The following options can be specified:

|               |                |                                         |
| ------------- | -------------- | --------------------------------------- |
| Background    | GrayLevel[0.2] | background color                        |
| ImagePadding  | None           | padding size to use around each image   |
| ImageSize     | Automatic      | display size of the collage             |
| Method        | Automatic      | method to use for packing images        |
| Padding       | Automatic      | padding scheme to use around each image |
| Resampling    | Automatic      | resampling method                       |

* Possible settings for ``ImagePadding`` are:

|                                |                                                        |
| ------------------------------ | ------------------------------------------------------ |
| None                           | no padding                                             |
| m                              | the same padding on all sides                          |
| {m, n}                         | m pixels on left and right, n pixels on bottom and top |
| {{left, right}, {bottom, top}} | different padding on different sides                   |

* ``Method`` can take one of the following settings:

|                  |                                   |
| ---------------- | --------------------------------- |
| "Rows"           | arrange in horizontal layers      |
| "Columns"        | arrange in vertical layers        |
| "Grid"           | a regular grid of images          |
| "ClosestPacking" | closest packing from the top left |

---

## Examples (31)

### Basic Examples (3)

Create an image collage from a list of images:

```wl
In[1]:= ImageCollage[{[image], [image], [image], [image]}]

Out[1]= [image]
```

---

Create a collage from a weighted list of images:

```wl
In[1]:= ImageCollage[{1 -> [image], 9 -> [image], 1 -> [image], 4 -> [image]}]

Out[1]= [image]
```

---

Collage of flags of G7 countries, weighted by their population:

```wl
In[1]:= list = Rule@@@EntityValue[CountryData["G7"], {"Population", "Flag"}]

Out[1]= {Quantity[3.5309555*^7, "People"] -> [image], Quantity[6.4101308*^7, "People"] -> [image], Quantity[8.1625599*^7, "People"] -> [image], Quantity[6.1175248*^7, "People"] -> [image], Quantity[1.26225259*^8, "People"] -> [image], Quantity[6.3556184*^7, "People"] -> [image], Quantity[3.22422965*^8, "People"] -> [image]}

In[2]:= ImageCollage[list, ImagePadding -> 3]

Out[2]= [image]
```

### Scope (4)

#### Weights (2)

With no weights specified, almost-equal weights are assumed:

```wl
In[1]:= images = {[image], [image], [image], [image]};
```

Images will appear to have roughly the same area:

```wl
In[2]:= ImageCollage[images]

Out[2]= [image]
```

Absolute weights represent a relationship between image areas in the collage:

```wl
In[3]:= ImageCollage[{1, 1, 4, 9} -> images]

Out[3]= [image]
```

Scaled weights get multiplied with original image dimensions:

```wl
In[4]:= ImageCollage[Scaled[Range[4]] -> images]

Out[4]= [image]
```

Use ``Scaled[1]`` as the weight for all images to preserve original image area ratios:

```wl
In[5]:= ImageCollage[Scaled[1] -> images]

Out[5]= [image]
```

---

Compatible ``Quantity`` objects can also be used as weights:

```wl
In[1]:= list = {Quantity[1, "Meters"] -> [image], Quantity[50, "Centimeters"] -> [image], Quantity[3, "Feet"] -> [image], Quantity[30, "Inches"] -> [image]};

In[2]:= ImageCollage[list]

Out[2]= [image]
```

#### Fitting (1)

Use different fitting schemes to specify how to fit images in the allocated space:

```wl
In[1]:= images = {[image], [image], [image], [image]};

In[2]:= Labeled[ImageCollage[images, #, 200, Method -> "Grid"], #]& /@ {"Fill", "Fit", "Stretch"}

Out[2]= {Labeled[[image], "Fill", {}], Labeled[[image], "Fit", {}], Labeled[[image], "Stretch", {}]}
```

#### Size (1)

If no size is specified, the collage size is influenced by the original dimensions as well as the method:

```wl
In[1]:= images = {[image], [image], [image], [image], [image], [image], [image], [image]};

In[2]:= ImageCollage[images]

Out[2]= [image]
```

Specify the output image width:

```wl
In[3]:= ImageCollage[images, Automatic, 300]

Out[3]= [image]
```

Specify the width and height of the output image:

```wl
In[4]:= ImageCollage[images, Automatic, {300, 100}]

Out[4]= [image]
```

Create a portrait collage:

```wl
In[5]:= ImageCollage[images, Automatic, {150, 300}]

Out[5]= [image]
```

### Options (12)

#### Background (4)

By default, the background is filled with ``GrayLevel[0.2]`` :

```wl
In[1]:= ImageCollage[Scaled[1] -> {[image], [image], [image], [image]}, ImagePadding -> 2]

Out[1]= [image]
```

---

Specify a background color:

```wl
In[1]:= ImageCollage[Scaled[1] -> {[image], [image], [image], [image]}, Background -> Orange, ImagePadding -> 2]

Out[1]= [image]
```

---

Use ``Background -> Transparent`` to create a collage with transparent background:

```wl
In[1]:= ImageCollage[Scaled[1] -> {[image], [image], [image], [image]}, Background -> Transparent, ImagePadding -> 2]

Out[1]= [image]

In[2]:= AlphaChannel[%]

Out[2]= [image]
```

---

With ``Padding -> Automatic``, images are padded with the background color:

```wl
In[1]:= list = Scaled[1] -> {[image], [image], [image], [image]};

In[2]:= ImageCollage[list, Background -> Black, ImagePadding -> 2]

Out[2]= [image]
```

Use a different padding value:

```wl
In[3]:= ImageCollage[list, Background -> Black, ImagePadding -> 2, Padding -> Orange]

Out[3]= [image]
```

#### Method (5)

By default, the packing method is automatically selected:

```wl
In[1]:= images = {[image], [image], [image], [image], [image], [image]};

In[2]:= ImageCollage[images, ImagePadding -> 2]

Out[2]= [image]
```

Specify the packing method:

```wl
In[3]:= ImageCollage[images, ImagePadding -> 2, Method -> "Rows"]

Out[3]= [image]
```

---

The ``"ClosestPacking"`` method tries to find a packing while preserving relative weighted image areas:

```wl
In[1]:= images = {[image], [image], [image], [image], [image], [image]};

In[2]:= ImageCollage[1 -> images, Method -> "ClosestPacking"]

Out[2]= [image]
```

---

The ``"Grid"`` method places the images in a regular grid:

```wl
In[1]:= images = {[image], [image], [image], [image], [image], [image]};

In[2]:= ImageCollage[images, "Stretch", ImagePadding -> 2, Method -> "Grid"]

Out[2]= [image]
```

---

The ``"Rows"`` method places images in horizontal layers:

```wl
In[1]:= images = {[image], [image], [image], [image], [image], [image]};

In[2]:= ImageCollage[images, ImagePadding -> 2, Method -> "Rows"]

Out[2]= [image]
```

Create vertical layers using ``Method -> "Columns"`` :

```wl
In[3]:= ImageCollage[images, ImagePadding -> 2, Method -> "Columns"]

Out[3]= [image]
```

---

With ``Method -> "Grid"``, by default all cells have the same size, equivalent to ``ItemSize -> All`` :

```wl
In[1]:=
SeedRandom[1];
images = Table[Image@Graphics[Disk[], Background -> RandomColor[], ImageSize -> RandomInteger[{20, 60}, 2]], {6}];

In[2]:= ImageCollage[images, "Stretch", Method -> "Grid", ImagePadding -> 2]

Out[2]= [image]
```

Use ``ItemSize -> Full`` to resize each grid cell to its full width and height:

```wl
In[3]:= ImageCollage[images, "Stretch", ImagePadding -> 2, Method -> {"Grid", ItemSize -> Full}]

Out[3]= [image]
```

#### ImagePadding (1)

By default, images are not padded:

```wl
In[1]:=
SeedRandom[0];
images = ConstantImage[RandomColor[], #]& /@ RandomInteger[{20, 40}, {12, 2}];

In[2]:= ImageCollage[images, Method -> "Rows"]

Out[2]= [image]
```

Specify the same padding size on all sides:

```wl
In[3]:= ImageCollage[images, Method -> "Rows", ImagePadding -> 5]

Out[3]= [image]
```

Specify different padding in the horizontal and vertical directions:

```wl
In[4]:= ImageCollage[images, Method -> "Rows", ImagePadding -> {5, 10}]

Out[4]= [image]
```

Specify different padding for each side:

```wl
In[5]:= ImageCollage[images, Method -> "Rows", ImagePadding -> {{5, 10}, {0, 20}}]

Out[5]= [image]
```

#### Padding (1)

By default, with ``Padding -> Automatic``, images are padded with the same color as ``Background`` :

```wl
In[1]:=
SeedRandom[0];
images = ConstantImage[RandomColor[], #]& /@ RandomInteger[{30, 60}, {12, 2}];

In[2]:= ImageCollage[images, ImagePadding -> 5, Method -> "Grid"]

Out[2]= [image]
```

Use a different ``Background`` :

```wl
In[3]:= ImageCollage[images, ImagePadding -> 5, Background -> White, Method -> "Grid"]

Out[3]= [image]
```

Specify a different padding:

```wl
In[4]:= ImageCollage[images, ImagePadding -> 5, Padding -> Red, Method -> "Grid"]

Out[4]= [image]
```

#### Resampling (1)

By default, a suitable resampling method is chosen:

```wl
In[1]:= i = Image[RandomInteger[1, {10, 10}]]

Out[1]= [image]

In[2]:= ImageCollage[{i, i}, Automatic, 100]

Out[2]= [image]
```

Specify the resampling method:

```wl
In[3]:= ImageCollage[{i, i}, Automatic, 100, Resampling -> "Gaussian"]

Out[3]= [image]
```

### Applications (5)

Create a collage where images are weighted by their median intensity:

```wl
In[1]:= images = {[image], [image], [image], [image], [image], [image]};

In[2]:= list = Table[ImageMeasurements[i, "MedianIntensity"] -> i, {i, images}];

In[3]:= ImageCollage[list]

Out[3]= [image]
```

---

Create a collage of thumbnails of all test images in ``ExampleData`` :

```wl
In[1]:= images = ExampleData[#, "Thumbnail"]& /@ ExampleData["TestImage"];

In[2]:= ImageCollage[images, ImagePadding -> 5, Background -> GrayLevel[.8]]

Out[2]= [image]
```

---

Create a collage of a collection of Picasso's notable paintings:

```wl
In[1]:= picassoartwork = EntityValue[\[FreeformPrompt]["picasso"], EntityProperty["Person", "NotableArtworks"]];
```

Get images as well as their corresponding areas for these paintings:

```wl
In[2]:= data = Cases[EntityValue[picassoartwork, {"Area", "Image"}], {_Quantity, _Image}];
```

Collage of paintings where each is shown at a size proportional to its original area:

```wl
In[3]:= ImageCollage[Rule@@@data, Automatic, 500, ImagePadding -> 2, Background -> White]

Out[3]= [image]
```

---

Collage of images of sample buildings, weighted by their number of floors:

```wl
In[1]:= list = Rule@@@(BuildingData[#, {"FloorCount", "Image"}]& /@ BuildingData["SampleEntities"])

Out[1]= {163 -> [image], 3 -> [image], 5 -> [image], 47 -> [image], 110 -> [image], 147 -> [image], 88 -> [image], 101 -> [image], 61 -> [image], 56 -> [image]}

In[2]:= ImageCollage[list]

Out[2]= [image]
```

---

Collage of multiple barcodes:

```wl
In[1]:=
images = {
	BarcodeImage["CODE 39", "Code39"], 
	BarcodeImage["Code 128", "Code128"], BarcodeImage["PDF 417 Code", "PDF417"], 
	BarcodeImage["QR Code", "QR"], 
	BarcodeImage["Aztec Code", "Aztec"]};

In[2]:= ImageCollage[Scaled@1 -> images, Background -> White, ImagePadding -> 15]

Out[2]= [image]
```

Recognize all barcodes in the collage:

```wl
In[3]:= BarcodeRecognize[%]

Out[3]= {"QR Code", "Aztec Code", "CODE 39", "PDF 417 Code", "Code 128"}
```

### Properties & Relations (3)

``ImageCollage`` works with all kinds of images:

```wl
In[1]:=
SeedRandom[1];
images = Table[Graphics[Disk[], Background -> RandomColor[], ImageSize -> RandomInteger[{20, 40}, 2]], {8}]

Out[1]= {[image], [image], [image], [image], [image], [image], [image], [image]}

In[2]:= ImageCollage[images]

Out[2]= [image]
```

``ImageAssemble`` requires regular images:

```wl
In[3]:= ImageAssemble[Partition[images, 4]]
```

ImageAssemble::row: Expecting images of the same height in one row.

```wl
Out[3]= ImageAssemble[{{[image], [image], [image], [image]}, {[image], [image], [image], [image]}}]
```

Use ``ConformImages`` to preprocess the set:

```wl
In[4]:= ImageAssemble[Partition[ConformImages[images], 4]]

Out[4]= [image]
```

---

Use ``Grid`` to visualize images in a regular grid:

```wl
In[1]:=
SeedRandom[1];
images = ConstantImage[RandomColor[], #]& /@ RandomInteger[{30, 80}, {6, 2}]

Out[1]= {[image], [image], [image], [image], [image], [image]}

In[2]:= Grid[Partition[images, 3], Background -> GrayLevel[.2]]

Out[2]=
|         |         |         |
| ------- | ------- | ------- |
| [image] | [image] | [image] |
| [image] | [image] | [image] |
```

---

Use ``WordCloud`` to assemble words in 2D layout:

```wl
In[1]:= (data = Tally[ToLowerCase /@ StringCases[ExampleData[{"Text", "ToBeOrNotToBe"}], WordCharacter..]])//Short

Out[1]//Short= {{"to", 15}, {"be", 4}, {"or", 2}, «164», {"my", 1}, {"sins", 1}, {"remember", 1}}

In[2]:= WordCloud[data]

Out[2]= [image]
```

### Possible Issues (1)

If the image set exhibits some regularity, the weights may be altered to create a more packed collage:

```wl
In[1]:=
SeedRandom[1];
images = ConstantImage[RandomColor[], #]& /@ Transpose[{RandomInteger[{30, 80}, 10], RandomInteger[{40, 50}, 10]}];

In[2]:= ImageCollage[images]

Out[2]= [image]
```

Explicitly set all weights to 1 to avoid area differences:

```wl
In[3]:= ImageCollage[1 -> images]

Out[3]= [image]
```

### Neat Examples (3)

Create a country population visualization by showing each country flag, weighted by its population:

```wl
In[1]:= list = EntityValue[EntityClass["Country", "Countries"], {"Flag", "Population"}];
```

Select countries that contribute to at least 0.2 percent of the world population:

```wl
In[2]:= th = N@Total[list[[All, 2]]] / 500

Out[2]= Quantity[1.4437928848000001*^7, "People"]

In[3]:= list2 = Select[list, #[[2]] > th&];
```

Create the collage:

```wl
In[4]:= ImageCollage[list2, ImagePadding -> 2, Background -> GrayLevel[.8]]

Out[4]= [image]
```

---

Make a collage of 20 disks of random color and size:

```wl
In[1]:= ImageCollage[Table[RandomReal[] -> Graphics[{RandomColor[], Disk[]}, ImageSize -> Tiny], {20}], Background -> White]

Out[1]= [image]
```

---

Nestedly apply ``ImageCollage`` :

```wl
In[1]:= NestList[ImageCollage[{#, #, #}]&, [image], 3]

Out[1]= {[image], [image], [image], [image]}
```

## See Also

* [`ImageAssemble`](https://reference.wolfram.com/language/ref/ImageAssemble.en.md)
* [`WordCloud`](https://reference.wolfram.com/language/ref/WordCloud.en.md)
* [`GraphicsGrid`](https://reference.wolfram.com/language/ref/GraphicsGrid.en.md)
* [`ImageCompose`](https://reference.wolfram.com/language/ref/ImageCompose.en.md)
* [`ImageAdd`](https://reference.wolfram.com/language/ref/ImageAdd.en.md)
* [`Blend`](https://reference.wolfram.com/language/ref/Blend.en.md)

## Related Guides

* [Image Composition](https://reference.wolfram.com/language/guide/ImageComposition.en.md)
* [Data Visualization](https://reference.wolfram.com/language/guide/DataVisualization.en.md)
* [Basic Image Manipulation](https://reference.wolfram.com/language/guide/BasicImageManipulation.en.md)
* [Computational Photography](https://reference.wolfram.com/language/guide/ComputationalPhotography.en.md)

## Related Workflows

* [Combine Multiple Images](https://reference.wolfram.com/language/workflow/CombineMultipleImages.en.md)

## History

* [Introduced in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) \| [Updated in 2015 (10.3)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn103.en.md)