ExifTool (Perl)
The reference reader and writer for image, audio and video metadata: about 225 Perl modules (plus 15 .pl files) whose tag tables are plain data (tag ID to name, format, conversion, write rules), walked by a small set of container procedures; it is the survey's model for a metadata vocabulary and the natural oracle for a Sparkles metadata explorer.
| Field | Value |
|---|---|
| Language | Perl 5 (core modules only; optional Compress::Zlib, Digest::MD5 and others) |
| License | Same terms as Perl itself: Artistic License or GPL (README); the LICENSE file holds the GPLv3 text |
| Repository | exiftool/exiftool |
| Revision read | 2200871d9cef988051d2a99d67df3bda6cbb30a8 (May 27, 2026; version 13.59) |
| Documentation | lib/Image/ExifTool/README (tag-table developer reference) · ExifTool.pod · exiftool |
| Category | Metadata: container walkers, tag tables, maker notes, metadata writing |
| Tier | B |
| Last reviewed | November 7, 2026 |
NOTE
Claims marked demonstrated come from running exiftool from the pinned clone (Perl 5.40.0, x86_64 Linux) against files crafted by a short Perl script in /tmp/exiftool-demo: a JPEG whose ExifOffset points back at IFD0, one whose IFD0 next-IFD pointer is itself, one with fifteen entries of an invalid TIFF type, one whose value size exceeds 2 GiB, and PNG and JPEG files written by ExifTool itself. Counts of tags and groups were read from exiftool -list, exiftool -listw and Image::ExifTool::GetAllGroups at the same revision.
Overview
What it solves
ExifTool answers "what metadata does this file carry, where exactly, and what does it mean", across more than two hundred file types. Its README describes it as "a customizable set of Perl modules plus a full-featured command-line application for reading and writing meta information in a wide variety of files, including the maker note information of many digital cameras" (README). It does not decode pixels: image data is located (offsets, lengths, an optional hash) and otherwise carried through untouched.
Design philosophy
The design philosophy is that knowledge lives in tables, not code. The developer reference opens with the contract every format module follows:
The tables in these files are used as lookups based on the tag ID values. The hash keys are the tag IDs (in decimal or hexadecimal if the ID is numerical as with EXIF tables, or the tag name if the ID is ASCII as with XMP tables). In the case of a BinaryData table, the IDs are numerical and specify offsets into the binary data block … (
README)
A handful of generic procedures (ProcessExif, ProcessBinaryData, ProcessMOV, ProcessPNG, ProcessRIFF, the XMP parser) interpret those tables; a new camera model is usually a table edit, not a new parser. Writing is conservative: by default "the original files are preserved with _original appended to their names" (exiftool DESCRIPTION).
How it works
Tag tables
A tag table is a Perl hash named after its module (%Image::ExifTool::Exif::Main, %Image::ExifTool::PNG::Main). Upper-case keys describe the table; every other key is a tag ID. The README lists "Twenty-eight special keys (TABLE_NAME, SHORT_NAME, PROCESS_PROC, WRITE_PROC, CHECK_PROC, …)" (README); the important ones are PROCESS_PROC (the walker for this directory type), WRITE_PROC, GROUPS (default group names), FORMAT (default binary format) and NAMESPACE (XMP).
The EXIF table header and two entries (Exif.pm, Exif.pm, Exif.pm):
%Image::ExifTool::Exif::Main = (
GROUPS => { 0 => 'EXIF', 1 => 'IFD0', 2 => 'Image'},
WRITE_PROC => \&WriteExif,
CHECK_PROC => \&CheckExif,
WRITE_GROUP => 'ExifIFD', # default write group
SET_GROUP1 => 1, # set group1 name to directory name for all tags in table
...
0x10f => {
Name => 'Make',
Groups => { 2 => 'Camera' },
Writable => 'string',
WriteGroup => 'IFD0',
DataMember => 'Make',
RawConv => '$val =~ s/\s+$//; $$self{Make} = $val',
},
...
0x112 => {
Name => 'Orientation',
Writable => 'int16u',
WriteGroup => 'IFD0',
PrintConv => \%orientation,
Priority => 0, # so PRIORITY_DIR takes precedence
},Each entry's tag-information hash carries, among nearly seventy documented keys (README):
- Identity and docs:
Name("Tag names need not be unique"),Description,Notes,Groups. - Decoding:
Format,Count,Mask/BitShiftfor packed fields inBinaryDatatables. - Three conversion stages:
RawConvruns at extraction time and may drop the tag or record state;ValueConvturns the raw value into a usable one;PrintConvmakes it human-readable, often as a lookup hash whose misses print as "Unknown (X)" (README,README). Each has an inverse (RawConvInv,ValueConvInv,PrintConvInv) for writing. - Dispatch:
Condition, a Perl expression over$self,$$valPt(the first 128 bytes of the value),$formatand$count; "If used in a list of alternate tag definitions, the first list entry with a true condition is taken" (README). - Writing:
Writable(a write format,0for read-only),WriteGroup,WriteAlso,Protected("Bit 0x01 indicates an 'Unsafe' tag … Bit 0x02 indicates a 'Protected' tag, which should not be set directly by the user",README),Permanent,Shiftfor date arithmetic (README). - Structure:
SubDirectory { TagTable, Start, Base, ByteOrder, Validate, ProcessProc, … }, which turns a tag into a pointer to another directory (README).
GetTagTable loads a module on first reference to one of its tables, fills default family 0 and 1 groups from the module name, registers XMP namespaces and merges user-defined tags from the config file (ExifTool.pm). Image::ExifTool::TagLookup is a generated index ("the lists below were generated by Image::ExifTool::BuildTagLookup") from tag name to the tables that define it, used to find where a tag may be written (TagLookup.pm). The same build step produces the TagNames HTML documentation, so the tables are their own reference manual.
Demonstrated: at this revision exiftool -list prints 21,488 tag names and exiftool -listw 7,235 writable ones.
Composite tags
Each module may declare a composite table (%Image::ExifTool::Exif::Composite), registered with AddCompositeTags into the shared %Image::ExifTool::Composite; it holds derived tags with Require, Desire and Inhibit lists of source tags. ImageSize requires ImageWidth and ImageHeight, desires ExifImageWidth, ExifImageHeight and RawImageCroppedSize, and picks among them by TIFF_TYPE (Exif.pm). A metadata explorer needs this layer: what a user means by "the image size" is a rule over several raw tags.
Walking containers
ExtractInfo reads the first $testLen = 1024 bytes and tries each type in @fileTypes against a regular expression in %magicNumber (ExifTool.pm), then calls Process<Type> from the module named in %moduleName. If nothing matches, it scans for an embedded JPEG or TIFF signature and warns "Processing $type-like data after unknown $skip-byte header" (ExifTool.pm).
Every nested directory goes through ProcessDirectory, which keeps the metadata path ($$self{PATH}), saves and restores byte order, and refuses a directory whose absolute address it has already processed (ExifTool.pm). Per container:
- JPEG.
ProcessJPEGwalks markers.APP1withExif\0hands the payload toProcessTIFF, after joining "multi-segment EXIF" across consecutiveAPP1segments (ExifTool.pm);APP2ICC_PROFILE\0reassembles numbered chunks, warning on duplicates and zero counts, before handing the whole profile to theICC_Profiletable (ExifTool.pm).APP10toAPP15cover HDR gain curves, JUMBF, Ducky, Photoshop, Adobe and GraphicConverter segments (ExifTool.pm). - TIFF IFDs.
ProcessExifreads the 12-byte entries; a tag with aSubDirectory(0x8769 ExifOffset,0x8825 GPSInfo,0x8773 ICC_Profile) recurses into a sub-directory: the same table forExifIFD, the GPS or ICC table otherwise (Exif.pm,Exif.pm). - ISOBMFF and QuickTime.
ProcessMOVreads 8-bytesize/typeheaders, handlessize == 1(64-bit extended size, refused above0x7fffffffunlessLargeFileSupportis set) andsize == 0(to end of file at the top level; inside a container, tolerated as the terminator Canon writes inCNTH), and mapsftypbrands to file types (QuickTime.pm,QuickTime.pm). Atom tables are keyed by the four-character type. - RIFF.
ProcessRIFFreadsa4Vchunk headers; aLISTchunk's tag ID is synthesised asLIST_<type>soLIST_INFOandLIST_hdrlget separate tables, and an all-zero chunk ID aborts with "Encountered empty null chunk" (RIFF.pm). - PNG.
ProcessPNGwalks chunks keyed by chunk type (iCCP,eXIf,cICPasCICodePoints,caBXfor C2PA,iTXtcarrying XMP), and the same procedure writes when$$dirInfo{OutFile}is set (PNG.pm,PNG.pm,PNG.pm).
Maker notes
EXIF tag 0x927c is not a tag but a conditional list: "handle maker notes as a conditional list" (Exif.pm). @Image::ExifTool::MakerNotes::Main is "NOT a normal tag table"; each entry picks a vendor table by header bytes or by the Make captured earlier by RawConv (MakerNotes.pm):
{
Name => 'MakerNoteNikon',
Condition => '$$valPt=~/^Nikon\x00\x02/',
SubDirectory => {
TagTable => 'Image::ExifTool::Nikon::Main',
Start => '$valuePtr + 18',
Base => '$start - 8',
ByteOrder => 'Unknown',
},
},Start and Base encode each vendor's offset convention, and ByteOrder => 'Unknown' guesses from the entry count. Editors that move a maker note without fixing its internal offsets are common, so FixBase collects the value pointers, compares them with where the data sits, and shifts the base (with a Canon special case that reads the original offset from a TIFF footer) (MakerNotes.pm).
Groups
Every extracted tag is labelled in nine group families (ExifTool.pod):
0) Information Type (eg. EXIF, XMP, IPTC)
1) Specific Location (eg. IFD0, ExifIFD, XMP-dc)
2) Category (eg. Author, Time)
3) Document Number (eg. Main, Doc1, Doc3-2)
4) Instance Number (eg. Copy1, Copy2, Copy3)
5) Metadata Path (eg. JPEG-APP1-IFD0-ExifIFD)
6) EXIF/TIFF Format (eg. int8u, int32u, undef, string)
7) Tag ID (eg. ID-271, ID-rights, ID-a9aut)
8) Alternate File Number (eg. File1, File2, File3)Families 0 and 1 follow file structure, family 2 is a logical category, and families 5 and 6 are produced only with SavePath and SaveFormat (ExifTool.pod). Demonstrated: GetAllGroups lists 115 family 0, 507 family 1 and 14 family 2 names; on the crafted JPEG,
$ exiftool -G0:1:2:5:6:7 -api SavePath -api SaveFormat -s -Make -Orientation cycle.jpg
[EXIF:IFD0:Camera:JPEG-APP1-IFD0:string:ID-271] Make: Tst
[EXIF:IFD0:Image:JPEG-APP1-IFD0:int16u:ID-274] Orientation: Rotate 90 CWand after ExifTool writes the same tags into a PNG (-EXIF:Make=Tst -Orientation#=6), the path becomes PNG-EXIF-IFD0 (a bare -Make= goes to PNG-TextualData instead), while XMP lands at PNG-InternationalText-XMP. Names are not unique, so a tag is addressed as Group:Name on the command line and GetGroup($tag, ':3:1:2') in the API.
Analysis
3. Colour and metadata
ExifTool is the widest catalogue of image metadata in the survey: EXIF, GPS, IPTC, XMP, Photoshop IRB, MPF, JUMBF and C2PA, ICC profiles parsed tag by tag, PNG cICP as CICP, and maker notes for dozens of vendors. It interprets, but it never applies: orientation is a value (Rotate 90 CW, raw 6 under -n), not a transform. The contrast with libraries that carry metadata as opaque blobs is direct: image-rs keeps four byte vectors and a parsed Orientation (image-rs); ImageSharp parses EXIF lazily into typed profiles (ImageSharp); OpenImageIO flattens metadata into ImageSpec attributes (OpenImageIO). ExifTool's three-level value (raw, value, print) and its location labels are what those models lack when a user asks why two readers disagree. Precedence between duplicates is explicit: a tag Priority, a PRIORITY_DIR (XMP wins in QuickTime except HEIC, QuickTime.pm), and Copy1, Copy2 instances in family 4.
4. I/O and codec architecture
Pull-based and random-access: walkers Seek and Read on a File::RandomAccess object or slice an in-memory buffer. There is no suspension; the unit of work is a whole file. The architecture is one table-driven interpreter per container family (TIFF IFD, ISOBMFF atom, RIFF chunk, PNG chunk, JPEG segment, binary record) plus per-format tables, which is the split sparkles:wired would express as a binary description (wired baseline). Reading and writing share tables, and for PNG the same procedure. FastScan levels trade completeness for speed by stopping early or skipping trailers.
5. Hostile input and safety
Robustness comes from bounds checks and warnings, not from a memory-safe decoder (Perl strings are bounded, so an over-read yields a short string, not a fault). The mechanisms, all demonstrated on crafted files:
- Cycles.
ProcessDirectoryrecords each directory address;ExifOffsetpointing back atIFD0yields "ExifIFD pointer references previous IFD0 directory", and a next-IFD pointer to itself yields "IFD1 pointer references previous IFD0 directory" (ExifTool.pm). - Warning budget.
ProcessExifaborts an IFD after more than ten warnings ("Too many warnings -- $dir parsing aborted"); with one valid entry followed by fifteen invalid-type entries the output holds elevenBad format (99)warnings and the abort (Exif.pm,Exif.pm). An invalid format in the first entry abandons the IFD at once, after one warning. - Size limits. A value whose
count * sizeexceeds0x7fffffffis skipped with "Invalid size (2415919104) for IFD0 tag 0x010e ImageDescription" (Exif.pm); arrays of more than 500 numeric values are summarised as "(large array of $count $formatStr values)" unlessIgnoreMinorErrorsis set (Exif.pm). - Writes refuse corruption. Writing
Orientationinto the cyclic JPEG fails with "Error: Corrupted JPEG image" and "0 image files updated".
Warn deduplicates messages and grades them minor or not; IgnoreMinorErrors lets a user push past minor ones (ExifTool.pm). Warnings are themselves tags (ExifTool:Warning), so a malformed file still produces a report. See hostile input and the hostile-input papers; what ExifTool does not have is a fuzzing harness in the tree.
9. Temporal, animation and containers
The QuickTime module reads timed metadata streams (GPS tracks, camera telemetry) under ExtractEmbedded, each sample a family 3 document (Doc1, Doc2-3; ExifTool.pod), and loads QuickTimeStream.pl only when ExtractEmbedded or an image-data hash is requested (QuickTime.pm). The document-number family is the general answer to "metadata about the third frame of the second embedded image": a path of indices, not a flat list.
10. Testing and conformance
t/ holds 114 .t scripts, 194 sample files in t/images, and expected-output .out files compared by t/TestLib.pm check with tolerance for floats and times (TestLib.pm). Each line records families 0, 1 and 2, the tag ID and both description and value, for example [PNG, PNG, Image] 9 - Color Type: Grayscale (PNG_2.out); write tests round-trip through memory and re-read (PNG.t). These outputs are a ready conformance corpus for a reader that wants to match ExifTool's names.
Not covered: 1, 2, 6, 7, 8 (ExifTool never decodes pixels, so it has no pixel model, generic pixel code, SIMD or GPU path, and its allocation is Perl's own strings and hashes).
Lessons for Sparkles
- Q5 The minimum metadata model has more than blobs: a tag needs a location (family 1), a container path (family 5), an on-disk format (family 6), an ID (family 7) and an instance, and a value in raw and display forms. ExifTool shows the full set; the design chooses how much to keep.
- Q5 Tag tables as static data map onto D well: a table of records with ID, name, format, write rules and a lookup for display names fits compile-time data and the
sparkles:metadataUDA vocabulary, and thePrintConvhashes are enum name tables. What does not transfer is the PerlevalinCondition,RawConvandSubDirectoryStart/Base; a D port needs those as functions or a small expression language. - Q5 Write rules are part of the vocabulary (
Writable,Protected,Permanent,WriteGroup); a read-only model would need a second pass to add them. - Q4 Container walking is a few interpreters (IFD, atom, chunk, segment, binary record) driven by declarations; this is the evidence for what a
sparkles:wiredbinary description must express: offsets relative to a movable base, byte order discovered at run time, pointers to sub-directories, conditional dispatch on leading bytes. - Q4 Maker notes need relocatable bases (
Start,Base,FixBase); any IFD reader that hard-codes "offsets are from the TIFF header" will misread them. - Q8 ExifTool is the oracle for a metadata explorer modelled on the font-explorer spec:
exiftool -j -G0:1:7 -ngives keys such asEXIF:IFD0:ID-271:Makethat a differential test can compare field by field,-v3and-htmlDumpgive byte offsets for an explorer's hex view, and thet/*.outfiles are expected outputs. It is GPL or Artistic licensed Perl, so it fits as a test-time oracle through Nix, not as shipped code; its tables are facts, but copying them wholesale would carry the licence. - Q8 The warning model (deduplicated, graded, reported as tags, capped per directory) suits an explorer that must show a damaged file rather than reject it.
- Q9 ExifTool keeps metadata wholly apart from pixel decoding; that supports a separate metadata package that codecs feed with located byte ranges.
Strengths
- The widest coverage of formats, vendors and maker notes in any open tool, maintained continuously.
- Tables double as documentation; the
TagNamespages are generated from them. - Raw, converted and printed values are all reachable (
-n,-b,#suffix on write). - Precise provenance per tag through nine group families, including full metadata path and on-disk format.
- Tolerant reader with explicit, deduplicated warnings, cycle detection and size limits.
- Conservative writer: preserves originals by default, refuses corrupt input, rebases maker notes.
Weaknesses
- Behaviour lives partly in Perl code strings (
Condition,RawConv,Start), so the tables are not portable data without an interpreter. - No in-tree fuzzing; robustness rests on bounds checks and a large sample corpus.
- Whole-file, synchronous processing; no streaming or suspension.
- Tag names are not unique, so consumers must carry group qualifiers to be unambiguous.
- Single-process Perl startup and module loading make it a poor library dependency for a native viewer.
Key design decisions and trade-offs
| Decision | Rationale | Trade-off |
|---|---|---|
| Format knowledge as tag tables, not parsers | a new camera or tag is a table edit; tables generate docs | behaviour leaks into Perl strings (Condition, RawConv) |
| Conditional lists for maker notes | one EXIF tag dispatches to dozens of vendor layouts | entry order matters; vendor offset quirks need FixBase |
| Raw, value and print forms for every tag | users and scripts each get the form they need | three conversions, and their inverses, to maintain per tag |
| Nine group families label every tag | duplicate names stay addressable with exact provenance | consumers must carry group qualifiers to be unambiguous |
| Warn and continue, with a per-IFD warning budget | a damaged file still yields a report | robustness rests on hand-written checks, not a fuzzed decoder |
| Preserve originals and refuse corrupt input | a metadata write cannot silently destroy a file | a malformed file cannot be repaired by writing to it |
Sources
- The pinned clone of exiftool/exiftool at
2200871d9cef988051d2a99d67df3bda6cbb30a8: the tag-table referencelib/Image/ExifTool/README,ExifTool.pm,Exif.pm,MakerNotes.pm,QuickTime.pm,RIFF.pm,PNG.pm,TagLookup.pm,ExifTool.pod, theexiftoolscript andt/. - Scratch demonstrations in
/tmp/exiftool-demo(crafted JPEG and PNG files), as described in the note above. - Related deep-dives: image-rs, ImageSharp, OpenImageIO, libvips, SAIL, Wuffs, libavif; the concepts page; the existing-code baseline.