Page 1 of 1

Help extract alpha coordinates

Posted: 2016-04-16T01:28:26-07:00
by dev.alex89
I need get size and coordinates of transparent area inside png image.
like 555x560+428+376 in some image.

And it works, but not always

original img http://kartinka.by/imagemagick/r0325.png
convert ./r0325.png -alpha extract -format "%@" info:

and result 1000x1000+0+0 <-- no coords

original img http://kartinka.by/imagemagick/r0051.png
convert ./r0051.png -alpha extract -format "%@" info:

and result 1299x945+0+0 <-- no coords

why on than images alpha extract does not work, how to make it work ?

Re: Help extract alpha coordinates

Posted: 2016-04-16T05:29:46-07:00
by snibgo
If you "-alpha extract" to a new output file, and look at that image with Gimp, and read the values with the eyedropper tool, you will see the values vary. That's why a simple "trim" doesn't trim anything.

"-fuzz X%" will take care of that.

I suppose you want to put an image within the frame. But the frame isn't entirely opaque, so you should probably fix that, eg by alpha extract, threshold and alpha copy.

Re: Help extract alpha coordinates

Posted: 2016-04-16T06:32:25-07:00
by dev.alex89
thanks snibgo, it great, it works !

i think fuzz 10 enough for all same images

Re: Help extract alpha coordinates

Posted: 2016-04-16T06:58:49-07:00
by dev.alex89
Can it take coordinates of two areas from http://kartinka.by/imagemagick/_0103.png

Or it is more difficult ?

Re: Help extract alpha coordinates

Posted: 2016-04-16T07:29:32-07:00
by snibgo
That image has two areas, one in the top half and the other in the bottom half. So "-crop x50%" to split the image.