Composite, then crop to smaller of two original images
Posted: 2017-06-28T10:06:55-07:00
I have several hundred PNG images of widely varying size, and a background image large enough to fit all of them. I would like to superimpose the smaller images on top of the larger one, then discard any of the background image that exceeds the bounds of the smaller original image.
In past when I've done this, I have used a basic composite command:
And then I've opened them all in Paint.net and manually cropped them one at a time, which is imprecise and takes HOURS.
I know you can do this by specifying the exact geometry on the command line. But none of the PNGs have the same dimensions, and I really don't see that it would save me any time to manually work out all those hundreds of different commands compared to cropping manually.
Is there a way to tell ImageMagick to just stick the smaller images on top of the larger ones and discard any pixels outside the bounds of the smaller one?
In past when I've done this, I have used a basic composite command:
Code: Select all
composite source.png background.jpg output.jpg
I know you can do this by specifying the exact geometry on the command line. But none of the PNGs have the same dimensions, and I really don't see that it would save me any time to manually work out all those hundreds of different commands compared to cropping manually.
Is there a way to tell ImageMagick to just stick the smaller images on top of the larger ones and discard any pixels outside the bounds of the smaller one?