INTRODUCTION
Let's say I have this image:
To the image I apply the mask in https://image.ibb.co/c5Nw6c/Mask.png (it's white, that's why I set it here). The mask is basically a message bubble with an arrow in the bottom right part.
The command (in bash) is the following:
size=`convert Mask.png -format "%wx%h" info:`
convert \( couple.jpg -channel rgba -alpha on -resize $size \) Mask.png -compose copy_opacity -composite -compose over -background transparent -flatten png:result.png
And the result is:
PROBLEM
Let's now check the next two images:
Image 2
Image 3
If we do the same with these two, we will obtain the following results:
What we see here is that in order for the mask to be applied correctly, the proportions must be similar, otherwise, depending on the original image's size, it might cropped in the bottom, or in the right.
QUESTION
How can I avoid the cropping problem and:
- Make the trimmed image (with respect to the mask) fill the whole mask without leaving any gaps and without losing proportions? I guess, by resizing, but how?
- Let the resized photo be centered (center of gravity) with respect to the mask?
Thank you very much for your answers.