Page 1 of 1

get selection coordinates

Posted: 2009-11-22T10:55:33-07:00
by romankr
Hi.. I need some help to build the proper command line code.

I have an image that have black borders, i need to select those black borders and get the selection coordinated.

here is a print screen that have such a selection: http://img137.imageshack.us/img137/9103/pic1j.png

so i just need to do that kind of selection and get the coordinates.

Thanks.

Re: get selection coordinates

Posted: 2009-11-22T13:44:05-07:00
by fmw42
I don't think IM can find the coordinates of the boundary around the black and return them to you. But you can easily trim the black areas to smallest image area and/or change the black to transparent. You can even make a mask of the non-black vs black areas and use that mask to merge images.

Can you explain why you need the coordinates?

Re: get selection coordinates

Posted: 2009-11-23T02:36:08-07:00
by romankr
Hi, thanks for your reply..

I'll explain why do i need the coordinates, maybe there is a better way to do what i need.

I'm trying to build an image cropper that will crop where the red lines in that image:
http://img339.imageshack.us/img339/9673/pic2t.png

so i need to know the high and low point of the black background.
maybe you have an idea on other way i can do that?

Thanks

Re: get selection coordinates

Posted: 2009-11-23T11:20:23-07:00
by fmw42
-trim will crop out as much black as possible so that the non-black areas will bound the image.

convert image.png -trim result.png

see http://www.imagemagick.org/script/comma ... s.php#trim

Re: get selection coordinates

Posted: 2009-11-24T17:06:55-07:00
by anthony
Warning the PNG result will probably contain the trim offset information. Using +repage after -trim or -crop is recommended to remove that information unless you actually want to see what was trimmed.