Suppose I have a bunch of images in a folder with different sizes. The goal is to fit images in a number of pages (e.g. A4) in a way that the whitespace is minimal. There shouldn't be any compression or resizing involved. It is acceptable that some images would be rotated.
Here is what I came up with but doesn't try to "fit" images in any way:
montage *.jpg -mode concatenate -tile 2x2 -page A4 -geometry +20+20 out.pdf
Is it possible using imagemagick and montage switches?
I guess the computational geometry algorithm should change the 2x2 and +20+20 part of the command above, right?
In ImageMagick 7 (7.0.10-23 or higher), there is a new feature for doing collages called Ashlar. But it resizes to fit all the provided images into the space allocated.
See https://imagemagick.org/script/formats.php#pseudo
The [1000x1000+5+5] specifies the output dimensions and the minimum spacing in x and y between images.
Here is A4 size result: