How do I scale a composite overlay to fill a background?
Posted: 2009-04-10T00:36:09-07:00
I have a number of photos (backgrounds) with various aspect ratios that I want to resize (reduce) to a height of 400, which means the width will vary with each photo. I also want to dissolve a logo image (overlay) with some transparency over each image (before or after the resize), so that the logo is as large as possible, but still fits within the background image.
I'm using the Command Line composite command in a Windows command prompt, but I can't work out how to scale the overlay to fit the background image, without cropping the overlay (with certain background aspect ratios).
The following code works well for squarish (1:1), background images, but for narrow background images, the logo gets cropped at the left and right, and for short background images, the logo gets cropped at the top and bottom.
I'm using the Command Line composite command in a Windows command prompt, but I can't work out how to scale the overlay to fit the background image, without cropping the overlay (with certain background aspect ratios).
The following code works well for squarish (1:1), background images, but for narrow background images, the logo gets cropped at the left and right, and for short background images, the logo gets cropped at the top and bottom.
Code: Select all
composite -gravity center logo.png[390x] pic1.jpg[x400] -dissolve 30 test1.jpg