Site logo,

Image metadata


Metadata are data about data. For an image, metadata comprise such things as when it was captured (ie, photographed), the exposure time, the name of the photographer, and so on, as opposed to the true data of the image which are the values of the pixels. The image would still be an image without its metadata; we could still display it and process it. Metadata are additional information which it can be useful to know. It can be more than just useful for some kinds of processing. If we want to graph the brightness or position of an object in a series of images changing against time we need the metadata which tell when each image was captured. To do the inverse gnomonic projection, to be able to join overlapping images, we need to know the focal length of the camera lens (which enables us to calculate the angle of the field of view that the projection algorithm really requires) and that is also usually stored in each image file as metadata.

The TIFF file format was designed from the outset to hold metadata as part of its structure. TIFF standard metadata which are relevant for GRIP include author (of the image, which we interpret as photographer), capture device (camera) make and model, and date and time of capture. TIFF's metadata format is easy to extend, so camera manufacturers have agreed further values such as exposure time in seconds, lens type, focal length range, actual focal length used, etc. One feature of TIFF's metadata is that fractional values are held as just that: there is a data type called rational and it holds two values, numerator and denominator. Reading a rational value therefore usually requires doing the division. For Java programmers, GRIP has a static utility method in class Util for doing this. Another class, ExifTag, lists all the TIFF metadata tags we need (and more), with their data types so that GRIP can use them.


Exif is another metadata structure, the standard for which was agreed by camera manufacturers. It is embedded in .jpg and RAW files. Internally it has the same basic structure as TIFF but finding the Exif part of an image file is different from navigating a TIFF file. GRIP has the classes Exif, ExifFile and ExifTag for the purpose.

The class Exif has a main method, enabling it to be run as a stand-alone application. This was originally intended for testing the class but you can use it for examining any image file to see what metadata can be found in it. It interprets many tags by giving their names but when studying RAW files some things are kept secret by the camera makers, so it is only possible to guess the meaning of some of the data, particularly in the tag called <MakerNote>. Use the following command to explore your files.

java -cp grip.jar net.grelf.image.Exif

Exif is fine for JPEG images produced in the camera. As explained on Wikipedia, software which processes the file and resaves it is unlikely to preserve all the Exif fields and so it is not useful for JPEG files in general.

Another metadata format is XMP. This was an Adobe standard but it has been adopted by the International Press Telecommunications Council (IPTC). XMP is used in PDF files and elsewhere. More information can be found on Wikipedia, under XMP and IPTC.

Metadata in XMP format can be found in JPEG files saved by Adobe applications and it does contain data which were originally in Exif when first written by the camera. So looking for XMP data is a better bet for JPEG files which have been edited. Using TextPad, it is possible to load an image file as binary data and see the character equivalents down the right hand side of the screen. This makes it possible to see what XMP or other tags are present. The following have been found in XMP sections in JPEG files saved by Photoshop CS2.


crs prefix is used for Adobe Camera Raw settings
Example of xmlDateTime: 2007-01-24T18:14:02Z

GRIP does not attempt to handle XMP because its serious use (eg, for astrophotography) requires images having at least 16 bits per channel and that means TIFF or FITS files.

See the image reading and writing page for more information about reading image metadata in Java.

Next page