Page 1 of 1

how to crop an image with a mask

Posted: 2016-01-26T13:10:47-07:00
by andreiya
Hi everyone,
I'm trying to do a simple images process, but my level of english and programing is low and is hard for me understand the imagemagick guide. I reviewed Fred's ImageMagick Scripts and neither found any solution.

I want to cut an image with a mask. This is my flow program

1 receive the image to mask and it's size
2 place the mask in the position that i want over the image
3 apply the mask to cut the shape
4 merge the result in other image on the desire position

I want to extract only the shape of the mask. I move the mask because in my image the original is bigger or smaller that mask(the image size to mask will change dynamically ), in case the size of image and mask be the same i don't move nothing.
In this case the mask cut all rose, but some tome i want cut only a part of the rose, for that move the mask to area to crop.
What can i do?

P.D:
My O.S is ubuntu and imagemagick version is:

Version: ImageMagick 6.8.9-9 Q16 x86_64 2015-08-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib




Image
Image
Image
Image
Image
Image

Re: how to crop an image with a mask

Posted: 2016-01-26T13:23:08-07:00
by Bonzo
Your last 3 mages are not displayed - need to change the privacy settings on dropbox?

Re: how to crop an image with a mask

Posted: 2016-01-26T14:20:01-07:00
by andreiya
Bonzo wrote:Your last 3 mages are not displayed - need to change the privacy settings on dropbox?
The images are public and I saw fine in the posting preview :shock:
I have reupload to imgur and I hope that works.
P.D: I visited your page, It 's fine, thanks for sharing

Re: how to crop an image with a mask

Posted: 2016-01-26T14:31:10-07:00
by snibgo
andreiya wrote:I want to cut an image with a mask.
I think you want to make some pixels transparent. Where the mask is black, make them transparent. Do this with "copy-opacity", for example:

Code: Select all

convert rose: mask.png -compose copy-opacity -composite out.png
Where the mask is 50% gray, pixels will be 50% opaque.

Re: how to crop an image with a mask

Posted: 2016-01-26T14:38:15-07:00
by andreiya
Thanks snibgo, I´m going to sleep. Tomorrow try your advice and repost

Re: how to crop an image with a mask

Posted: 2016-01-27T05:33:32-07:00
by Bonzo
P.D: I visited your page, It 's fine, thanks for sharing
Thank you