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

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
dxr528
Posts: 9
Joined: 2018-11-27T05:55:13-07:00
Authentication code: 1152

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

Post 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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
Post Reply