Code: Select all
magick m_src.png m_mask.png ( -clone 0 -alpha extract ) ( -clone 1 -clone 0 -compose multiply -composite ) -delete 1,2 -alpha off -compose copy_opacity -composite result.png
Code: Select all
magick m_src.png m_mask.png ( -clone 0 -alpha extract ) ( -clone 1 -clone 0 -compose multiply -composite ) -delete 1,2 -alpha off -compose copy_opacity -composite result.png
Yes, it should be.fmw42 wrote:I had hoped that functionally masking would be the same whether it was transparent or not.
Code: Select all
convert dst.png src.png -compose XX -composite out.png
convert dst.png src.png ( +clone -fill White colorize 100 ) -compose XX -composite out.png
But, what it produces for non-transparent images is just src.png. So I assumed that the same would happen for transparent images.snibgo wrote:
Let me put this another way. Take two commands, assuming dst.png src.png are the same sizes:
The commands are the same, except that the second command is masked, but the mask is entirely white. The results from these two commands should be identical (provided the compose settings XX are the same).Code: Select all
convert dst.png src.png -compose XX -composite out.png convert dst.png src.png ( +clone -fill White colorize 100 ) -compose XX -composite out.png
"-compose Src" should do exactly that. In this case, we will get two half-circles. In v6.9.2-5, that's what we get.fmw42 wrote:It would be nice to have a -compose method that operated the way I thought it did as per the result of my long command line. That is take dst where mask is black and src where mask is white whether transparent or not.
Unfortunately, this is not working for me on IM7, output image seems gone crazy:fmw42 wrote:The first is the image and second is the mask. So this should be the one that works.
Since you are using IM 7, change convert to magick.Code: Select all
magick m_src.png m_mask.png ( -clone 0 -alpha extract ) ( -clone 1 -clone 0 -compose multiply -composite ) -delete 1,2 -alpha off -compose copy_opacity -composite result.png
Code: Select all
magick m_src.png m_mask.png ( -clone 0 -alpha extract ) ( -clone 1 -clone 2 -compose multiply -composite ) -delete 1,2 -alpha off -compose copy_opacity -composite result.png
Code: Select all
convert -size 60x60 xc:none -fill red -draw "circle 35,21 35,3" m_src.png
convert -size 60x60 xc:none -fill blue -draw "circle 21,39 24,57" m_bgnd.png
convert -size 60x60 xc: -draw "polygon 0,59 59,0, 0,0" m_mask.png
Code: Select all
convert m_bgnd.png m_src.png m_mask.png -compose over -composite m_over_masked_6944_over.png
Code: Select all
convert m_bgnd.png m_src.png m_mask.png -compose src -composite m_over_masked_6944_src.png
Code: Select all
convert -size 60x60 xc:none -fill red -draw "circle 35,21 35,3" m_src.png
convert -size 60x60 xc:none -fill blue -draw "circle 21,39 24,57" m_bgnd.png
convert -size 60x60 xc: -draw "polygon 0,59 59,0, 0,0" m_mask.png
Code: Select all
convert m_bgnd.png m_src.png -compose over -composite m_over_masked_6944_over_nomask.png
Code: Select all
composite m_src.png m_bgnd.png m_mask.png m_over_masked.png
Code: Select all
magick m_src.png m_mask.png ( -clone 0 -alpha extract ) ( -clone 1 -clone 2 -compose multiply -composite ) -delete 1,2 -alpha off -compose copy_opacity -composite m_masked.png
magick m_bgnd.png m_masked.png -compose over -composite m_over_masked.png