Assuming you want to do this on the server side, you can create a backing bean that uses the imageinfo class. It understands a number of image formats, including JPEG, GIF, PNG and BMP.
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, that will fit in a stocking