Page 1 of 1
Need help making old -mask command work with 7.?
Posted: 2017-11-15T07:45:56-07:00
by dshimer
I have a mask which is a black to white gradient. Previously if I ran
Code: Select all
convert in.tif -mask mask.tif -level 30%,100%,.7 out.tif
I would get an output image which had out.tif modified in such a way that black parts of the mask were 100% changed, white 0% changed, and various shades of grey were modified in a smooth gradient of whatever effect. I tried the same thing on a machine with 7.0.7-11 installed and the same exact command yields a file that has a hard edged mask which looks like a pure black and white mask with the transition being somewhere near a midpoint threshold of the grey values.
Though I couldn't really come across a good explanation of why I thought I would try the -read-mask option and the magick command but that didn't help either. So I would love a pointer into how to accomplish what I need or where some examples or full documentation regarding how to apply a gradient mask can be found.
Re: Need help making old -mask command work with 7.?
Posted: 2017-11-15T08:37:46-07:00
by GeeMack
dshimer wrote: ↑2017-11-15T07:45:56-07:00I tried the same thing on a machine with 7.0.7-11 installed and the same exact command yields a file that has a hard edged mask which looks like a pure black and white mask with the transition being somewhere near a midpoint threshold of the grey values.
I've encountered the same issue using an input image, a gradient mask the same size as the input, and a command like this...
Code: Select all
magick in.tif -write-mask mask.tif -level 30%,100%,0.7 +write-mask out.tif
The output has a hard edge division about half way down, with the modified image above and the original input below. It does seem to be incorrect behavior, but maybe I'm also misunderstanding how "-write-mask" is supposed to work.
Using IM 7.0.7-11 I can get the correct result you describe with a command like this...
Code: Select all
magick in.tif ( -clone 0 -level 30%,100%,0.7 ) mask.tif -composite out.tif
That reads the input image, modifies a clone of it inside the parentheses, reads the gradient mask image, then composites the modified clone over the original input using the mask to create the graduated effect.
Re: Need help making old -mask command work with 7.?
Posted: 2017-11-15T08:52:45-07:00
by snibgo
The documentation for "-write-mask"
http://www.imagemagick.org/script/comma ... write-mask says:
This the same as using a mask used for composite masking operations, with grayscale values causing blended updates of the image the mask is attached to.
It isn't supposed to be boolean.
It should be used with "+write-mask".
The porting guide
http://www.imagemagick.org/script/porting.php says it should be used with "+mask", but that's wrong. ("+mask" raises an error.)
Re: Need help making old -mask command work with 7.?
Posted: 2017-11-15T09:18:07-07:00
by dshimer
@GeeMack Perfect.
Thanks!
GeeMack wrote: ↑2017-11-15T08:37:46-07:00
Using IM 7.0.7-11 I can get the correct result you describe with a command like this...
Code: Select all
magick in.tif ( -clone 0 -level 30%,100%,0.7 ) mask.tif -composite out.tif
That reads the input image, modifies a clone of it inside the parentheses, reads the gradient mask image, then composites the modified clone over the original input using the mask to create the graduated effect.
Re: Need help making old -mask command work with 7.?
Posted: 2017-11-15T09:22:18-07:00
by dshimer
I tried a couple dozen variations of information I found there but just couldn't get anything to work as a gradient. I appreciate the reminder to go read it again word for word because I picked up on the fact that
This polarity is the reverse of masks in version 6 of ImageMagick.