Possible bugs with masking in IM 7
Posted: 2018-05-03T10:18:02-07:00
IM 7.0.7.29 Q16
I am having trouble with using -region and -read-mask, -write-mask, -mask in IM 7. The results are either the whole image is processed or a black image. Perhaps I misunderstand how these work in IM 7.
Input:
In IM 6, I can do -region as follows, which works fine:
In IM7, I get a black image
The porting document says:
The porting document also says:
magick: option deprecated, unable to execute `-mask' at CLI arg 20 @ error/operation.c/CLIOption/5212.
The porting document also has an example:
magick: option deprecated, unable to execute `+mask' at CLI arg 6 @ error/operation.c/CLIOption/5212.
So the +mask above should be replaced with +write-mask. Also convert in IM 7 porting document should be replaced with magick and compare with magick compare.
However, the write-mask polarity in IM 7 seems to be opposite that of IM 6, so the above command is affecting the outside, not the inside as the original example did in Anthony's documents
The porting document says that as follows:
IM 6:
IM 7 (with mask polarity reversed):
With regard to -write-mask and -read-mask, these are failing for me as below with respect to -scale. Perhaps that is not a valid command for masking due to scale change.
IM7 -write-mask makes a black image
IM7 -read-mask does the scaling everywhere, not just the center circle
I am having trouble with using -region and -read-mask, -write-mask, -mask in IM 7. The results are either the whole image is processed or a black image. Perhaps I misunderstand how these work in IM 7.
Input:
In IM 6, I can do -region as follows, which works fine:
Code: Select all
convert lena.jpg \
-region 128x128+64+64 -scale 10% -scale 1000% +region \
lena_pixelate_region6.jpg
In IM7, I get a black image
Code: Select all
magick lena.jpg \
-region 128x128+64+64 -scale 10% -scale 1000% +region \
lena_pixelate_region7.jpg
The porting document says:
But I am not sure I understand what that means.-region
The draw transformations are relative to the upper left corner of the image, previously in IMv6 they were relative to the region.
The porting document also says:
But this does not seem to be true.For convenience, we continue to support the -mask option in version 7 to match the behavior of version 6.
Code: Select all
magick lena.jpg \
\( +clone -fill white -colorize 100 \
-fill black -draw "circle 128,128 64,128" -alpha off +write tmp.png -write mpr:circle +delete \) \
-mask mpr:circle -scale 10% -scale 1000% -mask \
lena_pixelate_mask7.jpg
The porting document also has an example:
Code: Select all
convert rose: -write-mask rose_bg_mask.png -modulate 110,100,33.3 +mask rose_blue.png
So the +mask above should be replaced with +write-mask. Also convert in IM 7 porting document should be replaced with magick and compare with magick compare.
However, the write-mask polarity in IM 7 seems to be opposite that of IM 6, so the above command is affecting the outside, not the inside as the original example did in Anthony's documents
The porting document says that as follows:
However, this example does not work the same as in IM 6. See https://www.imagemagick.org/Usage/masking/#write_maskVersion 7 supports masks for most image operators. ... From the command-line, you can associate a mask with an image with the -read-mask and -write-mask options. This polarity is the reverse of masks in version 6 of ImageMagick.
IM 6:
Code: Select all
convert rose: -mask rose_bg_mask.png -modulate 110,100,33.3 +mask rose_blue6.png
IM 7 (with mask polarity reversed):
Code: Select all
magick rose: -write-mask rose_bg_mask_negate.png -modulate 110,100,33.3 +write-mask rose_blue7.png
With regard to -write-mask and -read-mask, these are failing for me as below with respect to -scale. Perhaps that is not a valid command for masking due to scale change.
IM7 -write-mask makes a black image
Code: Select all
magick lena.jpg \
\( +clone -fill black -colorize 100 \
-fill white -draw "circle 128,128 64,128" -alpha off +write mask.png -write mpr:circle +delete \) \
-write-mask mpr:circle -scale 10% -scale 1000% +write-mask \
lena_pixelate_write7.jpg
IM7 -read-mask does the scaling everywhere, not just the center circle
Code: Select all
im7 magick lena.jpg \
\( +clone -fill black -colorize 100 \
-fill white -draw "circle 128,128 64,128" -alpha off +write mask.png -write mpr:circle +delete \) \
-read-mask mpr:circle -scale 10% -scale 1000% +read-mask \
lena_pixelate_read7.jpg