Page 1 of 1

Using a feathered mask to cut out a part of an image

Posted: 2014-01-28T23:24:22-07:00
by tasslehawf
This is the effect that I'm going for. I thought I wanted to create an "alpha" image to do the cut. Not sure now.

http://mhayesdesign.com/help_with_mask_cut.jpg

I'm using rmagick. I though that was what I was going for:
source = mask = Magick::Image.read("source_image.jpg")
mask = Magick::Image.read("mask_image.jpg")
source.composite!(mask, Magick::CenterGravity, Magick::OutCompositeOp)

I was trying to load the mask as a transparency, but it seems to flattening it.

Re: Using a feathered mask to cut out a part of an image

Posted: 2014-01-28T23:41:06-07:00
by fmw42
To use an image as an alpha channel, you need to use the equivalent of -compose copy_opacity to put (composite) the image into the alpha channel of the image. The composite the new image with alpha channel over the background image. Sorry I do not know Rmagick.

see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/compose/#copyopacity

Re: Using a feathered mask to cut out a part of an image

Posted: 2014-01-29T10:18:33-07:00
by tasslehawf
Even with the command line tool, I can't make it work at all in any visible way.
Here's the "alpha" image:
http://mhayesdesign.com/ahl_alpha.png

And the image I want to mask:
http://mhayesdesign.com/4308129_64_close.jpg
fmw42 wrote:To use an image as an alpha channel, you need to use the equivalent of -compose copy_opacity to put (composite) the image into the alpha channel of the image. The composite the new image with alpha channel over the background image. Sorry I do not know Rmagick.

see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/compose/#copyopacity

Re: Using a feathered mask to cut out a part of an image

Posted: 2014-01-29T10:47:25-07:00
by fmw42
try this

convert 4308129_64_close.jpg ahl_alpha.png -alpha off -compose copy_opacity -composite result1.png

or if you want the other part to show

convert 4308129_64_close.jpg \( ahl_alpha.png -negate \) -alpha off -compose copy_opacity -composite result2.png

On windows, use


convert 4308129_64_close.jpg ( ahl_alpha.png -negate ) -alpha off -compose copy_opacity -composite result2.png

Re: Using a feathered mask to cut out a part of an image

Posted: 2014-01-30T12:56:50-07:00
by tasslehawf
I've noticed a weird behavior. If I chose a name for the resulting image that's based on the name of the source image, the composition just gives me the source image. If I chose something else, like: blah.png. It works. All things the same, the file name is the only thing I'm changing.

Re: Using a feathered mask to cut out a part of an image

Posted: 2014-01-30T13:11:27-07:00
by fmw42
tasslehawf wrote:I've noticed a weird behavior. If I chose a name for the resulting image that's based on the name of the source image, the composition just gives me the source image. If I chose something else, like: blah.png. It works. All things the same, the file name is the only thing I'm changing.
Give me an example command line. That should not be happening. Also post links to your images if you can, so others can test. You can upload your images to say dropbox (public folder) and put links here.