Move Masked composition around over larger canvas

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?".
Post Reply
kimmyk
Posts: 40
Joined: 2018-11-01T13:07:06-07:00
Authentication code: 1152

Move Masked composition around over larger canvas

Post by kimmyk » 2018-11-17T04:40:29-07:00

Hi,

Been reading and trying to find a solution, but I can't find it.

I have 4 images:
1. profile image
2. mask
3. image to overlay over the masked profile image (like a wrapped plastic png)
4. the background image
"/usr/bin/magick \( ". $profile_pic ." -resize 300 \
". $mask ." -compose CopyOpacity -composite \
". $mask_overlay ." -compose Over -alpha set -background none -rotate -5 \) -composite \
\( ". $input ." -resize 600 \) +swap -compose Over -composite \
" . $output;
This code makes it look great (finally;-)), but, the mask is in the upper left corner of the image. I'd like to be able to move it around freely.
Is there no such easy way?

I have read this as well:
https://www.imagemagick.org/Usage/compose/
"Unfortunately while "-gravity" and "-geometry" settings will let you re-position the source image, the mask image is NOT re-positioned, and remains aligned with the destination image."

This is a solution given, but I don't know how to implement it in my code, my attempts failed:
convert tile_aqua.jpg tile_water.jpg \
\( -background black -splice 10x25+0+0 moon_mask.gif \) \
-composite mask_offset.jpg

I have tried various versions of moving my Grouped masking around but that produced off-set results

Anybody?

snibgo
Posts: 11687
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Move Masked composition around over larger canvas

Post by snibgo » 2018-11-17T05:15:23-07:00

You have a profile_pic that you make partially transparent with a mask, and composite over that with a mask_overlay. That gives an image that you want to compose somewhere over the input, correct?

Then insert "-geometry +40+50" or whatever immediately before "+swap".

If that doesn't do what you want, please link to sample files of the four images.
snibgo's IM pages: im.snibgo.com

kimmyk
Posts: 40
Joined: 2018-11-01T13:07:06-07:00
Authentication code: 1152

Re: Move Masked composition around over larger canvas

Post by kimmyk » 2018-11-17T06:09:26-07:00

snibgo wrote:
2018-11-17T05:15:23-07:00
You have a profile_pic that you make partially transparent with a mask, and composite over that with a mask_overlay. That gives an image that you want to compose somewhere over the input, correct?

Then insert "-geometry +40+50" or whatever immediately before "+swap".

If that doesn't do what you want, please link to sample files of the four images.
You rock ;-)
Sometimes it is everything you tried, but 1 haha.

Post Reply