({{, (RefLink[ImageCollage, paclet:ref/ImageCollage])[{(Subscript[image, 1]),(Subscript[image, 2]),…}]
creates a collage of images (Subscript[image, i]).}, {, (RefLink[ImageCollage, paclet:ref/ImageCollage])[{(Subscript[w, 1])->(Subscript[image, 1]),(Subscript[w, 2])->(Subscript[image, 2]),…}]
creates a collage of images (Subscript[image, i]) based on their corresponding weights (Subscript[w, i]).}, {, (RefLink[ImageCollage, paclet:ref/ImageCollage])[\[LeftAssociation](Subscript[image, 1])->(Subscript[w, 1]),(Subscript[image, 2])->(Subscript[w, 2]),…\[RightAssociation]]
also creates a collage of images (Subscript[image, i]) based on their corresponding weights (Subscript[w, i]).}, {, (RefLink[ImageCollage, paclet:ref/ImageCollage])[{(Subscript[w, 1]),(Subscript[w, 2]),…}->{(Subscript[image, 1]),(Subscript[image, 2]),…}]
also creates a collage of images (Subscript[image, i]) based on their corresponding weights (Subscript[w, i]).}, {, (RefLink[ImageCollage, paclet:ref/ImageCollage])[{{(Subscript[image, 1]),(Subscript[w, 1])},{(Subscript[image, 2]),(Subscript[w, 2])},…}]
also creates a collage of images (Subscript[image, i]) based on their corresponding weights (Subscript[w, i]).}, {, (RefLink[ImageCollage, paclet:ref/ImageCollage])[…,fitting]
uses the fitting method to create the collage.}, {, (RefLink[ImageCollage, paclet:ref/ImageCollage])[…,fitting,size]
creates a collage of the specified size.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ImageCollage, paclet:ref/ImageCollage]) creates a collage of a list of images and can be used to create a compact visualization of photographs, graphics, etc.

(RefLink[ImageCollage, paclet:ref/ImageCollage])[w->{(Subscript[image, 1]),(Subscript[image, 2]),…}] assumes the same weight w for all (Subscript[image, i]).

Weights (Subscript[w, i]) can be either of one of the following forms:

Possible values for fitting include:

The following options can be specified:

Possible settings for (RefLink[ImagePadding, paclet:ref/ImagePadding]) are:

(RefLink[Method, paclet:ref/Method]) can take one of the following settings:

OpenersPrimaryExamplesSection(Spacer1)Examples  (31)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Create an image collage from a list of images:

ImageCollage[{,,,}]

Create a collage from a weighted list of images:

ImageCollage[{1->,9->,1->,4->}]

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

list=Rule@@@EntityValue[CountryData["G7"],{"Population","Flag"}]

ImageCollage[list,ImagePadding->3]

OpenersExampleSection1(Spacer1)Scope  (4)

OpenersExampleSubsection0(Spacer1)Weights  (2)

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

images={,,,};

Images will appear to have roughly the same area:

ImageCollage[images]

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

ImageCollage[{1,1,4,9}->images]

Scaled weights get multiplied with original image dimensions:

ImageCollage[Scaled[Range[4]]->images]

Use (RefLink[Scaled, paclet:ref/Scaled])[1] as the weight for all images to preserve original image area ratios:

ImageCollage[Scaled[1]->images]

Compatible (RefLink[Quantity, paclet:ref/Quantity]) objects can also be used as weights:

list={(QuantityUnit[1])->,(QuantityUnit[50])->,(QuantityUnit[3])->,(QuantityUnit[30])->};

ImageCollage[list]

OpenersExampleSubsection1(Spacer1)Fitting  (1)

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

images={,,,};

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

OpenersExampleSubsection2(Spacer1)Size  (1)

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

images={,,,,,,,};

ImageCollage[images]

Specify the output image width:

ImageCollage[images,Automatic,300]

Specify the width and height of the output image:

ImageCollage[images,Automatic,{300,100}]

Create a portrait collage:

ImageCollage[images,Automatic,{150,300}]

OpenersExampleSection2(Spacer1)Options  (12)

OpenersExampleSubsection3(Spacer1)Background  (4)

By default, the background is filled with (RefLink[GrayLevel, paclet:ref/GrayLevel])[0.2]:

ImageCollage[Scaled[1]->{,,,},ImagePadding->2]

Specify a background color:

ImageCollage[Scaled[1]->{,,,},Background->Orange,ImagePadding->2]

Use (RefLink[Background, paclet:ref/Background])->(RefLink[Transparent, paclet:ref/Transparent]) to create a collage with transparent background:

ImageCollage[Scaled[1]->{,,,},Background->Transparent,ImagePadding->2]

AlphaChannel[%]

With (RefLink[Padding, paclet:ref/Padding])->(RefLink[Automatic, paclet:ref/Automatic]), images are padded with the background color:

list=Scaled[1]->{,,,};

ImageCollage[list,Background->Black,ImagePadding->2]

Use a different padding value:

ImageCollage[list,Background->Black,ImagePadding->2,Padding->Orange]

OpenersExampleSubsection4(Spacer1)Method  (5)

By default, the packing method is automatically selected:

images={,,,,,};

ImageCollage[images,ImagePadding->2]

Specify the packing method:

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

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

images={,,,,,};

ImageCollage[1->images,Method->"ClosestPacking"]

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

images={,,,,,};

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

The "Rows" method places images in horizontal layers:

images={,,,,,};

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

Create vertical layers using (RefLink[Method, paclet:ref/Method])->"Columns":

ImageCollage[images,ImagePadding->2,Method->"Columns"]

With (RefLink[Method, paclet:ref/Method])->"Grid", by default all cells have the same size, equivalent to (RefLink[ItemSize, paclet:ref/ItemSize])->(RefLink[All, paclet:ref/All]):

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

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

Use (RefLink[ItemSize, paclet:ref/ItemSize])->(RefLink[Full, paclet:ref/Full]) to resize each grid cell to its full width and height:

ImageCollage[images,"Stretch",ImagePadding->2,Method->{"Grid",ItemSize->Full}]

OpenersExampleSubsection5(Spacer1)ImagePadding  (1)

By default, images are not padded:

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

ImageCollage[images,Method->"Rows"]

Specify the same padding size on all sides:

ImageCollage[images,Method->"Rows",ImagePadding->5]

Specify different padding in the horizontal and vertical directions:

ImageCollage[images,Method->"Rows",ImagePadding->{5,10}]

Specify different padding for each side:

ImageCollage[images,Method->"Rows",ImagePadding->{{5,10},{0,20}}]

OpenersExampleSubsection6(Spacer1)Padding  (1)

By default, with (RefLink[Padding, paclet:ref/Padding])->(RefLink[Automatic, paclet:ref/Automatic]), images are padded with the same color as (RefLink[Background, paclet:ref/Background]):

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

ImageCollage[images,ImagePadding->5,Method->"Grid"]

Use a different (RefLink[Background, paclet:ref/Background]):

ImageCollage[images,ImagePadding->5,Background->White,Method->"Grid"]

Specify a different padding:

ImageCollage[images,ImagePadding->5,Padding->Red,Method->"Grid"]

OpenersExampleSubsection7(Spacer1)Resampling  (1)

By default, a suitable resampling method is chosen:

i=Image[RandomInteger[1,{10,10}]]

ImageCollage[{i,i},Automatic,100]

Specify the resampling method:

ImageCollage[{i,i},Automatic,100,Resampling->"Gaussian"]

OpenersExampleSection3(Spacer1)Applications  (5)

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

images={,,,,,};

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

ImageCollage[list]

Create a collage of thumbnails of all test images in (RefLink[ExampleData, paclet:ref/ExampleData]):

images=ExampleData[#,"Thumbnail"]&/@ExampleData["TestImage"];

ImageCollage[images,ImagePadding->5,Background->GrayLevel[.8]]

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

picassoartwork=EntityValue[LinguisticAssistant,(EntityProperty["notable artworks", EntityProperty["Person","NotableArtworks"], "EntityProperty[\"Person\", \"NotableArtworks\"]"])];

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

data=Cases[EntityValue[picassoartwork,{"Area","Image"}],{_Quantity,_Image}];

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

ImageCollage[Rule@@@data,Automatic,500,ImagePadding->2,Background->White]

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

list=Rule@@@(BuildingData[#,{"FloorCount","Image"}]&/@BuildingData["SampleEntities"])

ImageCollage[list]

Collage of multiple barcodes:

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

ImageCollage[Scaled@1->images,Background->White,ImagePadding->15]

Recognize all barcodes in the collage:

BarcodeRecognize[%]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

(RefLink[ImageCollage, paclet:ref/ImageCollage]) works with all kinds of images:

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

ImageCollage[images]

(RefLink[ImageAssemble, paclet:ref/ImageAssemble]) requires regular images:

ImageAssemble[Partition[images,4]]

Use (RefLink[ConformImages, paclet:ref/ConformImages]) to preprocess the set:

ImageAssemble[Partition[ConformImages[images],4]]

Use (RefLink[Grid, paclet:ref/Grid]) to visualize images in a regular grid:

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

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

Use (RefLink[WordCloud, paclet:ref/WordCloud]) to assemble words in 2D layout:

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

WordCloud[data]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

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

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

ImageCollage[images]

Explicitly set all weights to 1 to avoid area differences:

ImageCollage[1->images]

OpenersExampleSection6(Spacer1)Neat Examples  (3)

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

list=EntityValue[(EntityClass["all countries, dependencies, and territories", EntityClass["Country","Countries"], "EntityClass[\"Country\", \"Countries\"]", "countries"]),{"Flag","Population"}];

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

th=N@Total[list[[All,2]]]/500

list2=Select[list,#[[2]]>th&];

Create the collage:

ImageCollage[list2,ImagePadding->2,Background->GrayLevel[.8]]

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

ImageCollage[Table[RandomReal[]->Graphics[{RandomColor[],Disk[]},ImageSize->Tiny],{20}],Background->White]

Nestedly apply (RefLink[ImageCollage, paclet:ref/ImageCollage]):

NestList[ImageCollage[{#,#,#}]&,,3]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImageAssemble, paclet:ref/ImageAssemble])  ▪  (RefLink[WordCloud, paclet:ref/WordCloud])  ▪  (RefLink[GraphicsGrid, paclet:ref/GraphicsGrid])  ▪  (RefLink[ImageCompose, paclet:ref/ImageCompose])  ▪  (RefLink[ImageAdd, paclet:ref/ImageAdd])  ▪  (RefLink[Blend, paclet:ref/Blend])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Image Composition, paclet:guide/ImageComposition])}, {▪(RefLinkPlain[Data Visualization, paclet:guide/DataVisualization])}, {▪(RefLinkPlain[Basic Image Manipulation, paclet:guide/BasicImageManipulation])}, {▪(RefLinkPlain[Computational Photography, paclet:guide/ComputationalPhotography])}})}})