enclose a shape with a rectangle
enclose a shape with a rectangle
I have a white shape over a black background and I want the coordinates of the two points that define the smallest rectangle that encloses the given shape. To get those values I have to compute the distance from the left boarder to the shape and from the top boarder to the shape. Has someone PerlMagick code for this? Thank you very much!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: enclose a shape with a rectangle
I don't know Perl. From the command line, you can get the rectangle's width and height, and top-left corner, from:
Code: Select all
convert in.png -format %@ info:
snibgo's IM pages: im.snibgo.com
Re: enclose a shape with a rectangle
thank you!! This helps for now!snibgo wrote:I don't know Perl. From the command line, you can get the rectangle's width and height, and top-left corner, from:Code: Select all
convert in.png -format %@ info:
Re: enclose a shape with a rectangle
PerlMagick for
is
Code: Select all
convert in.png -format %@ info:
Code: Select all
$geometry = $in_png->Get('bounding-box');
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: enclose a shape with a rectangle
Thanks for posting the answer.
snibgo's IM pages: im.snibgo.com