Composite transparent layer and underlying layer

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Composite transparent layer and underlying layer

Post by fmw42 »

If we do that, it would distort either the background image or the frame image. If you want to do the frame image, then you can always distort it perfectly to match the background image.

try

Code: Select all

background="Ah4mtPw.jpg"
frame="mo9LQCx.gif"
size=`convert $background -format "%wx%h" info:`
convert $background \( $frame -resize $size! \) -gravity center -compose over -composite result.png

If the two images' aspect ratios are different, you will have to distort one or the other. There is no way to make them fit without distortion, unless you crop or pad as the code I provided earlier.
buchert
Posts: 36
Joined: 2015-02-13T11:15:29-07:00
Authentication code: 6789

Re: Composite transparent layer and underlying layer

Post by buchert »

Okay thanks for your help fmw42. I've decided to pad the images that are not wide enough with this command:

Code: Select all

convert aaa.jpg -bordercolor black -border 30x0 result.jpg
Post Reply