Value Conversions
Underlying Philosophies
Why Perl?

"Under the Hood" of ExifTool

This page explains some details of ExifTool's inner workings.

Overview of ExifTool

Below is a diagram showing the flow of information for the exiftool application. Indicated outside the boxes on the diagram are some command-line options associated with the various stages of processing. All of these options are directly associated with options or function calls available via the API (Application Programming Interface), with the exception of the output text formatting which is handled at the application level.

ExifTool Overview

The information flow is separated into two distinct modes: 1) Reading or extracting information, and 2) Writing or editing. The application runs in read mode by default, but switches to write mode if a new value is assigned to any tag (via "-TAG=", "-tagsFromFile", "-geotag", "-csv=" or "-json=" on the command line).

Value Conversions

When ExifTool reads or writes the value of a tag, there are 3 separate conversions applied to each value, resulting in 4 different levels for the value of each tag. By default, users interact only with the human-readable ("PrintConv") value, but other levels are exposed through various exiftool options:

  1. The "PrintConv" value is the final human-readable value which has been converted for display. Often, the "PrintConv" conversion will translate numbers into words for better readability. The -lang (Lang) option is used to specify the language for this conversion, and the -c and -d (CoordFormat and DateFormat) options specify this formatting for GPS coordinates and date/time values.
  1. For numerical values, the "ValueConv" value is a machine-readable value suitable for use in calculations, typically converted to standard units (eg. degrees, meters, or seconds). For date/time values the standard EXIF date/time format is used ("YYYY:mm:dd HH:MM:SS" plus decimal seconds and time zone if they exist). For tags which are a closed choice of string, this is the stored value of the string. The ValueConv value is returned for all tags when the -n option is used, or for individual tags by suffixing the tag name with a # character.
  1. The "Raw" value is the value after initial formatting is applied to the binary data from the file. Most tags have no separate "ValueConv" conversion, so for these tags the "Raw" value is the same as the "ValueConv" value. Values stored in rational form also have a "Rational" value. Both Raw and Rational values may be seen by using the -v option.
  1. The "Binary" value is the actual binary data stored in the file. This data is displayed in hexadecimal form with the -v3 option, or by using the -htmlDump feature. Note that this value is not related to the -b (-binary) option, which actually returns the "ValueConv" value and is used for tags where this value can not be presented in a simple text format. The Writable column in the Tag Name documentation gives the format of this binary data for writable tags.

Below are some examples of these different values for a few tags:

Tag3. PrintConv2. ValueConv1. Raw (Rational)0. Binary
EXIF:OrientationHorizontal (normal)11
00 01
EXIF:GPSLatitude45 deg 20' 11.00"45.336388888888945 20 11
(45/1 20/1 11/1)
00 00 00 2d 00 00 00 01
00 00 00 14 00 00 00 01
00 00 00 0b 00 00 00 01
XMP:GPSLatitude45 deg 20' 11.00"45.336388888888945,20.183333N "45,20.183333N"
00 00 00 01 00 00 00 1e
00 00 4d 9c 00 00 0f d1
EXIF:ModifyDate(set by -d option)2016:11:25 11:56:392016:11:25 11:56:39 "2016:11:25 11:56:39\0"
XMP:ModifyDate(set by -d option)2016:11:25 11:56:39.00-05:002016-11-25T11:56:39.00-05:00 "2016-11-25T11:56:39.00-05:00"

Underlying Philosophies

You have the right to know about the metadata contained in your images. A main goal of the Exiftool project is to make this information freely available, both to the general public and as a resource for other developers.

In the design of exiftool, there have been a number of underlying philosophies which have helped to influence the overall development:

  1. Make Image::ExifTool as independent as possible from other libraries to make it portable and easy to install. (Portable to a wide range of systems and Perl versions.)
  2. Keep the interface simple for simple tasks (sometimes at the expense of making it more complicated for complex tasks).
  3. The API functions should be isolated from the details of the metadata formats (otherwise the interface turns into a giant hairball, like the metadata).
  4. Maintain flexibility to allow users the freedom to do what they want (eg. support user-defined tags).
  5. Design the code to be efficient for batch processing, even if it increases the initial overhead.
  6. When writing files, remember 3 things: 1) data integrity, 2) data integrity, and 3) data integrity. If you can't do it right, don't do it at all.
  7. If possible, recognize file types by their structure, not by their extension.
  8. Maintain backward compatibility when making changes to the ExifTool API or command line application.

Why Write ExifTool in Perl?

At the start of ExifTool development, Perl, Python and C++ were all considered as possible languages for the project. It was recognized that the project would require considerable effort, and the choice of language could heavily influence the amount of work necessary. Python was a strong contender, but was discounted due to a personal preference for C-like syntax. Perl was chosen over C++ for the main reason that it would be less work to develop and support the project. Looking back, this was definitely the right choice, and there was the added benefit of a strong infrastructure in support of testing and distributing Perl software.

Perl 5 is very mature and extremely stable, so there is almost zero time wasted dealing with compilation issues. Compare this to C++, where a majority of development time for a large project may be spent in this area. Also, Perl's built-in regular expressions are fantastically useful for all of the string manipulations necessary for a metadata library. The biggest problem with Perl is its lack of support for Windows Unicode file names.

The bottom line is that most of the development time is spent dealing with the mechanics of metadata, with the result that ExifTool is full-featured metadata library. With one main developer (Phil Harvey) and 288 thousand lines of code (as of Feb 2024), this is a real accomplishment.

Created Jun 24, 2009
Last revised Feb 9, 2024

<-- Back to ExifTool home page