3

This old question asked how to combine 2 images into a single image side by side.

I want to do something different - combine 4 images into a grid.

So I have 4 png files, all the same size

+----------+  +----------+  +----------+  +----------+
|          |  |          |  |          |  |          |
|          |  |          |  |          |  |          |
|  PNG 1   |  |  PNG 2   |  |  PNG 3   |  |  PNG 4   | 
|          |  |          |  |          |  |          |
|          |  |          |  |          |  |          |
+----------+  +----------+  +----------+  +----------+

What I want to end up with is a single png file like this:

+----------+----------+
|          |          |
|          |          |
|  PNG 1   |   PNG 2  |
|          |          |
|          |          |
+----------+----------+
|          |          |
|          |          |
|  PNG 4   |   PNG 3  |
|          |          |
|          |          |
+----------+----------+

I actually have 34 sets of 4 files that I want to combine like this.

How can most easily I do this via the command line in macOS?

FWIW I currently have installed the latest versions of

  • Affinity Photo

  • Affinity Designer

  • Inkscape (with the extension for running python scripts inside Inkscape)

So anything that fits into one of these applications would be preferred.

Peter M
  • 848

2 Answers2

2

Montage

ImageMagik includes a Montage feature:

The original use of "magick montage" is to generate tables of image thumbnails, that is, to reference thumbnails of large collections of images, especially photos. And while it still can be used for that purpose, it can also do a lot more.

magick montage balloon.gif medical.gif present.gif shading.gif  montage.jpg

enter image description here

See also append images using a grid.

Graham Miln
  • 43,776
0

PNG 2 x 2 grid

Pages

  1. open a new blank document
  2. use Page Setup to define a custom paper size that is square
  3. use Document to change to page layout
  4. add a table with 2 rows and 2 columns
  5. position the table to fill the page
  6. format the rows and columns to be half the dimensions used for the custom page size
  7. format each of the table cells to be image fill
  8. choose each image for the cells
  9. export the document to PDF

Preview

  1. open the PDF file
  2. export to PNG
Eric
  • 155
  • 1
    While this is a solution, the OP asked "How can most easily I do this via the command line in macOS?" Could you supply a command line script that will accomplish what you suggest? – agarza Oct 04 '22 at 19:33