Help extract alpha coordinates

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
dev.alex89
Posts: 12
Joined: 2011-07-03T04:02:30-07:00
Authentication code: 8675308

Help extract alpha coordinates

Post 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 ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Help extract alpha coordinates

Post 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.
snibgo's IM pages: im.snibgo.com
dev.alex89
Posts: 12
Joined: 2011-07-03T04:02:30-07:00
Authentication code: 8675308

Re: Help extract alpha coordinates

Post by dev.alex89 »

thanks snibgo, it great, it works !

i think fuzz 10 enough for all same images
dev.alex89
Posts: 12
Joined: 2011-07-03T04:02:30-07:00
Authentication code: 8675308

Re: Help extract alpha coordinates

Post by dev.alex89 »

Can it take coordinates of two areas from http://kartinka.by/imagemagick/_0103.png

Or it is more difficult ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Help extract alpha coordinates

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply