Layer image A over image B using grayscale mask from image C

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
prohtex
Posts: 4
Joined: 2016-12-20T11:45:27-07:00
Authentication code: 1151

Layer image A over image B using grayscale mask from image C

Post by prohtex »

I'm trying to perform a masking operation. I'd like to layer image A, which is a jpg, over image B, also a jpg, applying first an opacity mask in the form of a greyscale tif file to image A. I'm also rotating and scaling the mask as I load it. I'm able to create a png with transparency using this code:

Code: Select all

convert \( images/010-Scan-005.jpg \( mask.tif[5002x6238] -rotate 180 \) -alpha Off -compose CopyOpacity -composite images_depaper/010-Scan-005.jpg.png
but when i tie this together with the other image, the transparency does not seem to work:

Code: Select all

convert \( images/014-Scan-007.jpg \( mask.tif[4982x6230] -rotate 180 \) -alpha Off -compose CopyOpacity -composite \) test.jpg -composite images_depaper/014-Scan-007.jpg
Help! Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Layer image A over image B using grayscale mask from image C

Post by snibgo »

prohtex wrote:... -compose CopyOpacity -composite \) test.jpg -composite images ...
Your "-compose" is a setting for "composite". But it affects both occurrences of "-composite". overriding the default (which is "over") for the second. So insert "-compose Over" before the second.
snibgo's IM pages: im.snibgo.com
Post Reply