The return of masking image

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
webshaker
Posts: 16
Joined: 2007-07-25T15:42:25-07:00

The return of masking image

Post by webshaker »

Well.
I've post a message few days oge, but finally it doen't really explain what I need.

I have a jpeg image like this
http://www.webshaker.net/imagemagick/src.jpg

I have a gif mask image
http://www.webshaker.net/imagemagick/black-mask.gif
or this one
http://www.webshaker.net/imagemagick/white-mask.gif
I dont' know which one i usefull

and I want a gif transparent destination image like this
http://www.webshaker.net/imagemagick/result.gif

And I do not succed to combine this image to obtain the right result !!!
Can somebody help me please ?

Thank's
Etienne
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: The return of masking image

Post by Bonzo »

Its strange but as I try to save your images the only option I get is bmp not jpg or gif as the file extension in the link.
This is done using php but you should be able to modify it to what you want:

Code: Select all

<?php
exec("convert -size 100x100 xc:none -fill black -draw \"circle 50,50 50,1\" mask.png");
exec("composite -compose Dst_In mask.png -gravity center untitled.bmp -matte result_dst_In1.png");
?> 
<img src="mask.png">
<img src="result_dst_In1.png">
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: The return of masking image

Post by el_supremo »

This will produce the result using the command line:

Code: Select all

convert src.jpg ( black-mask.gif +matte -negate ) -compose CopyOpacity -composite result.gif
A couple of questions/problems for the Wizards.

If I change the output of the above command to result.png the png file does not have the matte layer, even if I add -matte before -compose or after -composite. However if I just do "convert result.gif result.png" the png is correct.

If I change the command even further so that it gets the original images from the net:

Code: Select all

convert http://www.webshaker.net/imagemagick/src.jpg ( http://www.webshaker.net/imagemagick/black-mask.gif +matte -negate ) -compose copyopacity -composite result.png
it fails with the message
no encode delegate for this image format 'result.png'

I'm using IM6.3.5-4 Q8 on WinXP Pro.
Pete
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: The return of masking image

Post by anthony »

Due to the nature of "-compose copyopacity -composite" the resulting image should always have a matte channel (not layer) regardless of what the input images has. however the overlay image should NOT have a matte channel if it is a greyscale mask, If it does have a matte channel, it is the matte channel that is copied (as implied by the compose) rather than the greyscale values.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply