You are here

Number of pixels in selection

Hi Im looking for a plug in or a command in GIMP that will tell me the number of pixels in a selection of an image, then copy that number to the clipboard using the mouse. Histogram will tell me the number of pixels I have selected, but I cant copy the actual number off of the histogram window with the mouse cursor.


and paste in the following command: (cadddr (gimp-histogram (car (gimp-image-get-active-drawable [IMAGE])) HISTOGRAM-VALUE 0 256)) replacing [IMAGE] with the image number (from the top of the layer panel), or if only one image open, use this: (cadddr (gimp-histogram (car (gimp-image-get-active-drawable (vector-ref (cadr (gimp-image-list)) 0))) HISTOGRAM-VALUE 0 256)) and it will return the number of pixels in the selection. Note this is alpha weighted, so transparent pixels aren't counted. -Rob A>

I pasted in the last code posted in your reply to my post. When I did I got the following error message.. Error: Procedure execution of gimp-histogram failed

It should work if you have an active layer in the image. Can someone else try it and report? -Rob A>

It works (gimp-2.6.6 on linux)

and on 2.6.7. for: XP Vista 32 bit Ubuntu (Jaunty) I haven't tried 2.7 on Vista 32 bit yet.

Thanks for testing. Most likely a version issue - what version gimp are you using? -Rob A>
Subscribe to Comments for "Number of pixels in selection"