The READ_EXIF function reads Exif (Exchangeable image file format) metadata from JPEG, TIFF, and BigTIFF files.

The routine returns an IDL dictionary containing all of the Exif tags within the file. The Exif tags typically contain the image's date and time, GPS location, camera settings, a thumbnail, copyrights, or other information.

This routine is written in the IDL language. Its source code can be found in the file in the lib subdirectory of the IDL distribution.


Access the Exif metadata within a JPEG file:

IDL> filename = FILEPATH('Clouds.jpg', SUBDIR=['examples','data'])
IDL> result = READ_EXIF(filename, THUMB_IMAGE=thumb)
  "ifd1": {
    "Exif_Image_XResolution": 72.000000000000000,
    "Exif_Image_YResolution": 72.000000000000000,...
  "ifd0_subifd0_EXIF": {...},
  "ifd0": {
    "Exif_Image_XResolution": 72.000000000000000,
    "Exif_Image_Orientation": 1,
    "Exif_Image_DateTime": "2006:06:07 09:39:08",
    "Exif_Image_YResolution": 72.000000000000000...
IDL> PRINT, result.DateTime
2006:06:07 09:39:08

Now display the thumbnail image:

IDL> i = IMAGE(thumb)


Result = READ_EXIF( Filename, THUMB_DATA=variable, THUMB_IMAGE=variable )

Return Value

The result is an IDL object of class EXIFMetadata that is a subclass of Dictionary. If the file has no Exif data then the result is !NULL.

The dictionary contains all of the EXIF tags organized into IFD's (image file directories). Each IFD is itself a dictionary containing the actual key/value pairs. If the IFD contains a "sub-IFD", this will be returned as a separate item within the main dictionary.

An example result might look like:

  "ifd0": {
    "Exif_Image_Model": "iPhone 5s",
    "Exif_Image_Orientation": 6,
    "Exif_Image_DateTime": "2014:10:01 19:35:18",
  "ifd0_subifd0_EXIF": {
    "Exif_Photo_PixelYDimension": 2448,
    "Exif_Photo_PixelXDimension": 3264,
  "ifd0_subifd0_GPS": {
    "Exif_GPSInfo_GPSLongitude": [105.0000, 0.0000000, 0.0000000],
    "Exif_GPSInfo_GPSLatitudeRef": "N",
    "Exif_GPSInfo_GPSLongitudeRef": "W",
    "Exif_GPSInfo_GPSLatitude": [40.0000, 0.0000000, 0.0000000],
    "Exif_GPSInfo_GPSAltitude": 1667.0468750000000,

You can access any field within the result using the standard dictionary "dot" notation:

IDL> PRINT, result.ifd0.Exif_Image_DateTime
2014:10:01 19:35:18

However, to make it even easier, you can specify the last portion of a tag. READ_EXIF will then search through all of the tags to find a match:

IDL> PRINT,result.GPSLatitude
39.000000       58.000000       3.3900000



A string containing the name of a JPEG or TIFF file.



Set this keyword to a named variable in which the thumbnail data will be returned. The thumbnail data is returned as a byte array containing a raw JPEG byte stream. To retrieve the thumbnail from this byte stream, you could save the data out to a binary file and then use READ_JPEG. Or, you could use the THUMB_IMAGE keyword to retrieve just the image.


Set this keyword to a named variable in which the thumbnail image will be returned. The thumbnail image is returned as a 3xMxN byte array containing the image.


  1. READ_EXIF understands and parses all known Exif data types. For undefined datatypes, the data will be returned as a raw byte array.
  2. There are several fields that use APEX units to store their values. For example, ShutterSpeedValue uses an APEX unit defined on a logarithmic scale. READ_EXIF will return the raw APEX unit value.
  3. The Orientation value is given by a lookup table. The following table shows the conversion between the Exif orientation and the value used by IDL's ROTATE function:




IDL Rotate


1 Horizontal (normal) 0
2 Mirror horizontal [X,Y] →[–X,Y] 5
3 Rotate 180° [X,Y] →[–X,–Y] 2
4 Mirror vertical [X,Y] →[X,–Y] 7

Mirror horizontal, rotate 90° counterclockwise [X,Y] →[Y,X]

6 Rotate 90° clockwise [X,Y] →[–Y,X] 1
7 Mirror horizontal, rotate 90° clockwise [X,Y] →[–Y,–X] 6
8 Rotate 90° counterclockwise [X,Y] →[Y,–X] 3

Version History



See Also