Skip to content
Advertisement

Generate a value to reflect the average brightness of an image

I need to determine if an image is above a certain brightness. Using a scale of 0 – 255 I want to generate a value within this range to reflect the image brightness.

i.e. a white image is 255 and a black image is 0.

All this needs to take place via a bash script I am building up at the moment. I have no idea what image lib could do this for me though.

Advertisement

Answer

Try ImageMagick gray stats or histogram

convert rose: -colorspace gray -format "%[fx:100*mean]%%" info:
Advertisement