find coordinates of bounding box of transparent pixels

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?".
Post Reply
ravikum
Posts: 34
Joined: 2013-03-20T05:35:37-07:00
Authentication code: 6789

find coordinates of bounding box of transparent pixels

Post by ravikum »

Hello,
I have some png images with transparent areas like this with one or more holes :
Image

Image

the edges are semi transparent.

Please help me in finding the coordinates of the top left corner and bottom right corner of the bounding box of the transparent area like this.
Image

Image

Thanks
(using the latest IM version on linux centos 6)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: find coordinates of bounding box of transparent pixels

Post by fmw42 »

see -trim or string format "%@"

Code: Select all

convert dwrl3t.png -format "%@" info:
56x70+22+55

see
http://www.imagemagick.org/script/comma ... s.php#trim
http://www.imagemagick.org/script/escape.php
ravikum
Posts: 34
Joined: 2013-03-20T05:35:37-07:00
Authentication code: 6789

Re: find coordinates of bounding box of transparent pixels

Post by ravikum »

Thanks a lot.
It worked very well.
(using the latest IM version on linux centos 6)
Post Reply