I use openHAB and want to use an old mobile phone as an day/night indicator. I have installed a webcam app and it is filming the sky.

I can get the latest shot via http://[ip]/shot.jpg. Can I get a "brightness value" like this: curl http://[ip]/shot.jpg | some-command --get-brightness?


Two possibilities:

  1. Use imagemagick to check the brightness of the image will work as long as the phone camera does not have auto-exposure or it is turned off, otherwise it will only work for extreme values, (dark/light), e.g. convert <image> -colorspace Gray -format "%[fx:quantumrange*image.mean]" info:
  2. exiftool can parse the EXIF information from the file and extract the "Light Value" which should give you a reasonably consistent reading, (assuming that the camera on your specific phone includes this tag).

Both tools are free, gratis & open source and available for most platforms.

  • I just tested the convert command, it works and returns a number like 6310.78 or 13553.1 – Nicolas Raoul Sep 7 '16 at 6:56
  • 1
    @NicolasRaoul - so now all you have to do is calibrate your values for the camera and the view that it has. – Steve Barnes Sep 7 '16 at 7:58
  • Is the Ubuntu/Debian package graphicsmagick-imagemagick-compat enough? – Motte001 Sep 7 '16 at 16:02
  • @Motte001 - I think last time I just used sudo apt-get install imagemagick. – Steve Barnes Sep 7 '16 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.