In Imagemagick command line, you can convert to HSI or LAB and get the brightness (Intensity or Luminosity) from the average of the I or L channel. Any of these methods should work. Note that -scale 1x1 does a simple average of the whole image/channel and saves that value in 1 pixel result. -scale is very fast. It is not like -resize, which uses a specific filter function. Alternately, you can just compute the mean of the image without writing to 1 pixel.
convert image -colorspace HSI -channel b -separate +channel -scale 1x1 -format "%[fx:100*u]\n" info:
convert image -colorspace LAB -channel r -separate +channel -scale 1x1 -format "%[fx:100*u]\n" info:
convert image -colorspace HSI -channel b -separate +channel -format "%[fx:100*u.mean]\n" info:
convert image -colorspace LAB -channel r -separate +channel -format "%[fx:100*u.mean]\n" info:
convert image -colorspace HSI -channel b -separate +channel -format "%[mean]\n" info:
convert image -colorspace LAB -channel r -separate +channel -format "%[mean]\n" info:
The result will be between 0 and 100% with 0 being black and 100 white for all but the last two, where fx range is between 0 and 1. Thus the 100 factor to get percent. For the last two commands, the values will be between 0-255 for Q8 install and 0-65535 for Q16 install.
Note that channels are labeled in order as if they were r,g,b. But for modern versions of Imagemagick, you can use 0,1,2.
Alternately, you can get the pixel color for the channel which will be some gray value:
convert image -colorspace HSI -channel b -separate +channel -scale 1x1 -format "%[pixel:u.p{0,0}]\n" info:
convert image -colorspace LAB -channel r -separate +channel -scale 1x1 -format "%[pixel:u.p{0,0}]\n" info:
Sorry I do not know Imagick, but see
http://us3.php.net/manual/en/imagick.scaleimage.php
http://us3.php.net/manual/en/imagick.getimagepixelcolor.php
http://us3.php.net/manual/en/imagick.transformimagecolorspace.php
http://us3.php.net/manual/en/imagick.getimagechannelstatistics.php
or possibly
http://us3.php.net/manual/en/imagick.getimageproperty.php
Perhaps an Imagick expert would be kind enough to convert one of these commands from command line to Imagick code.