Page 2 of 2

Re: how to dig a hole of specified size from a JPG image

Posted: 2018-12-05T20:02:44-07:00
by fmw42
Save the original alpha channel. Then create a mask for you hole. Then multiply the alpha channel and the mask. Then put the result back into the alpha channel of the original image.

Re: how to dig a hole of specified size from a JPG image

Posted: 2018-12-05T22:36:52-07:00
by dxr528
fmw42 wrote: 2018-12-05T20:02:44-07:00 Save the original alpha channel. Then create a mask for you hole. Then multiply the alpha channel and the mask. Then put the result back into the alpha channel of the original image.
Can you help me to make the command with convert? thank you!

Re: how to dig a hole of specified size from a JPG image

Posted: 2018-12-06T00:01:01-07:00
by fmw42
Sorry, I do not code in your API, but only using the command line.

Here is how to do it in command line:

Code: Select all

magick 58a40d9d85367.png \
\( -clone 0 -alpha extract \) \
\( -clone 0 -alpha off -fill white -colorize 100 -fill black -draw "rectangle 200,200 400,400" -alpha off \) \
\( -clone 1 -clone 2 -compose multiply -composite \) \
-delete 1,2 -alpha off -compose copy_opacity -composite result.png