Extract Clipping Image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extract Clipping Image

Post by snibgo »

ckunchala wrote:is it possible to combine both commands into single command?
Yes, you can put all those options in a single command.

ckunchala wrote:Any specific reason to keep result in PNG ?
You didn't say what output file you wanted, so I used PNG as an example. The image is flattened so has no transparency, so JPG could be used. But JPG is only 8 bits/channel/pixel, and is lossy-compressed, so I suggest you never use it unless you really have to, and certainly NOT as an intermediate file that will be further processed.
snibgo's IM pages: im.snibgo.com

ckunchala
Posts: 8
Joined: 2020-01-29T11:08:28-07:00
Authentication code: 1152

Re: Extract Clipping Image

Post by ckunchala »

yeah understood, and thank you so much for your help. :)

ckunchala
Posts: 8
Joined: 2020-01-29T11:08:28-07:00
Authentication code: 1152

Re: Extract Clipping Image

Post by ckunchala »

Hi Experts,

one more question on this topic, is it possible to outline with the some color through out the edges of clipping image.

for example, if you see the image at http://img.buzzram.de/uploads/158704148 ... 7_at_11.27 , we can see the outline with blue color across the edges of clipping image.

Thanks million.

Best,
Chandra

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extract Clipping Image

Post by snibgo »

We can turn all fully-transparent pixels into transparent red. Then we extract the alpha channel, dilate the white areas, and copy the opacity back to the image. The result has a red outline. Windows BAT script:

Code: Select all

magick ^
  1584707760age.jpg ^
  -profile sRGB.icc ^
  -alpha transparent ^
  -clip -alpha opaque +clip ^
  -background Red -alpha background ^
  ( +clone ^
    -alpha extract ^
    -morphology dilate disk:5 ^
  ) ^
  -alpha off ^
  -compose CopyOpacity -composite ^
  out.png
snibgo's IM pages: im.snibgo.com

Locked