A contact sheet puts thumbnails in a grid so you can review several images in one file.
dotnet add package RecursiveAI.OneImageRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneImage; string[] files = ["red.png", "green.png", "blue.png", "yellow.png"]; int columns = 2, tileW = 80, tileH = 60; int rows = (files.Length + columns - 1) / columns; int width = columns * tileW, height = rows * tileH; var sheet = Image.FromPixels<Rgba32>( new Rgba32[width * height], width, height); for (int i = 0; i < files.Length; i++) sheet = sheet.Composite( Image.Load(files[i]).Resize(tileW, tileH), x: i % columns * tileW, y: i / columns * tileH); sheet.Save("contact-sheet.png"); Console.WriteLine("Saved contact-sheet.png");
Put your own file names in files. Writes contact-sheet.png. The four solid-color PNG inputs are included in the zip and regenerated by the full program.
Saved contact-sheet.pngUnzip the example, then dotnet run.
The full program
The four inputs are 80 × 60 opaque red, green, blue and yellow images. The program generates them, composites a two-column grid, and prints each tile’s center pixel. File-loading errors can surface when pixels are read or the sheet is saved, because image operations are lazy.
using OneImage; string[] files = ["red.png", "green.png", "blue.png", "yellow.png"]; Rgba32[] colors = [new(255, 0, 0, 255), new(0, 255, 0, 255), new(0, 0, 255, 255), new(255, 255, 0, 255)]; for (int i = 0; i < files.Length; i++) Image.FromPixels<Rgba32>(Enumerable.Repeat(colors[i], 80 * 60).ToArray(), 80, 60).Save(files[i]); var sheet = Image.FromPixels<Rgba32>(new Rgba32[160 * 120], 160, 120); for (int i = 0; i < files.Length; i++) sheet = sheet.Composite(Image.Load(files[i]).Resize(80, 60), x: i % 2 * 80, y: i / 2 * 60); sheet.Save("contact-sheet.png"); Console.WriteLine($"contact-sheet.png: {sheet.Width} x {sheet.Height}"); for (int i = 0; i < files.Length; i++) { var pixel = new Rgba32[1]; sheet.CopyPixelsTo<Rgba32>(pixel, new ImageRect(i % 2 * 80 + 40, i / 2 * 60 + 30, 1, 1)); Console.WriteLine($"Tile {i}: {pixel[0].R}, {pixel[0].G}, {pixel[0].B}"); }
contact-sheet.png: 160 x 120 Tile 0: 255, 0, 0 Tile 1: 0, 255, 0 Tile 2: 0, 0, 255 Tile 3: 255, 255, 0
Variations
For filled tiles without stretching, replace the thumbnail expression in the loop with:
Image.Load(files[i]).Resize(80, 60, fit: Fit.Cover)With the supplied inputs this produces the same dimensions and tile pixels as the full program. Fit.Cover matters when your source aspect ratios differ.
Related recipes
The short answer
Create a blank image with Image.FromPixels, resize each source, then assign the result of Composite back to the sheet. Compute the column with i % columns and the row with integer division i / columns. Multiply those coordinates by your tile dimensions before passing them to Composite. Save the resulting image after the loop, not after each tile.
The example uses explicit input names, which fixes the reading order. The compositing reference documents Composite as source-over composition at pixel coordinates. It is not an automatic montage API: your code owns the order, grid size and spacing.
How to make an image contact sheet?
First choose the number of columns and the size of each cell. For a nonempty input list, the required row count is (files.Length + columns - 1) / columns. Without gutters, the canvas width is columns * tileWidth and its height is rows * tileHeight. Keep these calculations consistent with the placement coordinates. An incomplete final row leaves the unused cells as the background you created.
The full program fixes the canvas at 160 × 120 for four 80 × 60 cells. It reads back the middle pixel from each tile, so you can see the row-major placement in the printed result: red and green occupy the first row, blue and yellow the second.
When using your own inputs, enumerate them in the intended order before placing them. A contact sheet is a visual index, so a stable mapping from filename to cell matters. If you add margins, start each tile at the margin plus its grid offset. If you add gutters, include that extra distance in the cell stride and in the total canvas size.
How do I resize photos for a contact sheet?
Use a fixed cell size and decide whether cropping is acceptable. The resize guide describes Fit.Contain as fitting inside the requested box and Fit.Cover as filling and cropping it. Fit.Pad preserves the whole image while padding to the box. Fit.Stretch ignores the aspect ratio. The variation uses Cover when every tile must be filled.
The default resize can return a thumbnail smaller than its box along one axis. That is not an error, but it leaves unused space in a fixed grid. For portraits and landscapes in the same sheet, pick Cover for equal filled rectangles or Pad for equal rectangles that retain the whole picture. Do not use Stretch unless changing the source proportions is intentional.
Can I create an image contact sheet for free?
OneImage is free and open source under MIT or Apache-2.0. The example uses its core NuGet package and generates its sample inputs locally. The download includes a pinned project, so it can reproduce the code on the page without acquiring photographs.
The output here is a PNG image, not a paginated PDF or a print-layout document. Choose its pixel dimensions for the thumbnails you need. A larger canvas does not restore detail that was removed by resizing. Image operations return new images, and the work is computed when pixels are requested or a file is saved; keep the final sheet returned by each composition.