Page 1 of 1

The return of masking image

Posted: 2007-08-01T03:17:23-07:00
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

Re: The return of masking image

Posted: 2007-08-01T12:24:29-07:00
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">

Re: The return of masking image

Posted: 2007-08-01T12:59:07-07:00
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

Re: The return of masking image

Posted: 2007-08-09T23:16:10-07:00
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.