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.
Using a feathered mask to cut out a part of an image
-
- Posts: 3
- Joined: 2014-01-28T23:07:37-07:00
- Authentication code: 6789
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Using a feathered mask to cut out a part of an image
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
see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/compose/#copyopacity
-
- Posts: 3
- Joined: 2014-01-28T23:07:37-07:00
- Authentication code: 6789
Re: Using a feathered mask to cut out a part of an image
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Using a feathered mask to cut out a part of an image
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
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
-
- Posts: 3
- Joined: 2014-01-28T23:07:37-07:00
- Authentication code: 6789
Re: Using a feathered mask to cut out a part of an image
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Using a feathered mask to cut out a part of an image
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.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.