💬Comments welcome. To leave a note, select any text and click the note / highlight button that pops up — or open the panel with the tab at the top-right (‹). Notes are visible only inside our private review group.
jump to

22.12 EXIF and image metadata

A photograph is never only its pixels. Tucked into the same file is a second, smaller record — when the shot was taken, with what lens, at what aperture, which way is up, and sometimes exactly where on Earth the photographer was standing. This is EXIF (Exchangeable image file format), and it is the camera's own account of how the image came to be. It is worth a short appendix for two reasons. First, it is genuinely useful: half of computational photography starts by reading the exposure triangle or the lens model out of EXIF, and a viewer cannot even display a phone snapshot the right way up without consulting the orientation tag. Second, it is genuinely treacherous: the coverage is patchy, some of the most-wanted numbers are rounded approximations rather than physical measurements, and the same metadata that helps you organize a library will quietly broadcast your home address. The goal here is a working map of what is in there, sorted by what it means, with the trust and privacy caveats attached.

22.12.1 What EXIF is

EXIF is structured metadata embedded in the image file itself — not a separate sidecar, but bytes that travel inside the JPEG, TIFF, or RAW/DNG you copied off the card. In a JPEG it rides in the APP1 marker segment, a stretch of the file the image decoder skips over on its way to the pixels; inside that segment the payload is a little TIFF/IFD structure — an image file directory, a table of tags mapping a numeric key to a value. The format is standardized (the Exif specification, maintained today as JEITA/CIPA DC-008), and a companion standard, DCF (Design rule for Camera File system), governs the prosaic business of how cameras name files and folders on the card so that any device can read any card. The practical upshot is that EXIF is portable: the metadata is part of the picture, so it survives a copy or an email — for better (your settings come along) and for worse (so does your GPS track).

The reason the container is a TIFF directory is historical and convenient: TIFF already had a tag-table format, so Exif borrowed it, which is why the same tag vocabulary shows up whether you are reading a JPEG's APP1 block, a TIFF, or a raw file's embedded metadata. A tag is just (key, type, value), and a file can carry several directories — one for the main image, one for an embedded thumbnail, one for the GPS block, one for the maker's private extensions.

EXIF is not the only block. A photo commonly carries two further metadata standards riding alongside it. XMP is Adobe's XML-based metadata — where Lightroom and Adobe Camera Raw stash edit settings, keywords, and star ratings, and the one place that, for a raw file, often lives in a separate sidecar .xmp rather than embedded in the picture (precisely because the raw itself is meant to stay untouched). IPTC is the older press-and-captioning standard, the vocabulary of newsrooms and stock libraries: caption, byline, credit, keywords, location. The three co-occur, and — being filled by different software at different times — they can quietly disagree, a copyright string or a capture date present in two of them but edited in only one. This is mostly a reason to reach for a tool that reads all three at once rather than squinting at EXIF alone; exiftool does exactly that.

22.12.2 The fields, grouped by what they describe

The tags are easiest to hold in your head sorted not by their numeric order but by what part of the act of photography they record.

Capture settings are the exposure story: the exposure time (shutter speed), the f-number (aperture), the ISO, and the supporting cast — the exposure program or mode (was the camera in aperture-priority, manual, or full auto?), the metering mode, the exposure bias the photographer dialed in, and whether the flash fired and how. This is the group everyone reads first, because it is the one that says how much light, gathered how.

Optics records the glass: the focal length, usually alongside a 35 mm-equivalent so a number from a tiny phone sensor is comparable to one from a full-frame body; the lens make and model; and, when the camera knows it, the subject or focus distance. Together with the capture settings this is enough to reason about depth of field, diffraction, and field of view after the fact.

Image describes the picture as data: the pixel width and height, the color space or an embedded ICC profile, the white-balance tag — and, quietly the most important field in the entire standard, the orientation flag. Cameras with an accelerometer record which way they were held and store the upright image plus a "rotate me" instruction rather than physically rotating the pixels; a viewer that ignores the orientation tag shows every portrait-mode photo on its side. It is the single tag a body chapter most needs to remember exists.

Time carries two dates that are easy to confuse: DateTimeOriginal, when the photo was taken, and DateTimeDigitized, when it was written or scanned. For a digital capture they coincide; for a film scan, or a re-encode, they diverge, and software that sorts by the wrong one shuffles a scanned archive into nonsense. Sub-second and time-zone tags refine the timestamp.

Place is the GPS block — latitude, longitude, altitude, and often a heading and its own timestamp — written by phones and GPS-equipped cameras. It is the most useful field for organizing a trip and the most dangerous to share.

MakerNotes is the manufacturer's private annex: a proprietary, largely undocumented blob where each vendor stashes the things the standard never named — the true (un-rounded) sensitivity, in-camera lens-correction coefficients, the shutter actuation count, the picture-style settings. Much of the genuinely interesting information lives here, which is also why reading it reliably is the province of specialized tools that have reverse-engineered each maker's dialect.

Two more odds and ends round it out. Most files carry an embedded thumbnail, a small JPEG for fast previews — and RAW files carry a full-resolution embedded preview, the already-developed JPEG your camera shows you on its screen before any of your editing software has touched the raw sensor data. And a scattering of identity tags — software, artist and copyright, camera and lens serial numbers, owner name — attach the file to a person and a device.

22.12.3 How far to trust it

EXIF is the camera's claim, and claims are uneven. Two failure modes recur. The first is coverage: not every camera writes every field, and makers disagree about which tags to fill and how, so a pipeline that assumes a tag is present will eventually meet a file where it is not. The second, more insidious, is fidelity. Some of the most-read numbers are nominal, not measured. The reported ISO and shutter speed are typically rounded to the familiar photographic stops and are not radiometrically exact — the sensor's true sensitivity and the actual integration time can differ by a noticeable fraction. So EXIF is the right place to learn roughly how a shot was exposed and the wrong place to source numbers for a calibrated radiometric computation; for that you measure, you do not read the tag. The rule that keeps you out of trouble is to treat EXIF as a helpful annotation and never as ground truth.

Don't calibrate off EXIF

Reading exposure time and ISO from EXIF to recover absolute radiance — for HDR response estimation, say — is a classic trap: the values are rounded to stops and are not the true integration time or gain. Use them as a starting guess; recover the real response from the pixels (the radiometric-calibration story in Multiple exposure imaging).

22.12.4 Privacy: the metadata that follows the picture

Because EXIF travels with the file, it leaks more than people expect. A photo posted from home can carry the GPS coordinates of the living room it was shot in; a batch of images can be tied to a single body or lens through their serial numbers; and owner-name and copyright tags name the photographer outright. None of this is visible in the picture, which is exactly why it surprises people. Many sharing platforms now strip EXIF on upload — which protects privacy but also explains why an image saved from the web arrives stripped of its settings — but the protection is not universal, and the safe assumption is that a file you hand someone carries everything the camera wrote. When that matters, strip it deliberately (for example, exiftool -all= clears every tag), rather than trusting the next service in the chain to do it for you.

22.12.5 Reading and writing EXIF

In practice the reference tool is exiftool, which has by far the widest tag coverage and is fluent in the per-vendor MakerNote dialects; exiv2 is a common library alternative. From Python, piexif and Pillow (Image.getexif()) cover the standard tags, and the C library libexif sits underneath many readers. For this book's own purposes the pipeline reads EXIF to do exactly the prosaic, useful things the standard is good at: apply the orientation flag so the book's photographs display upright, and pull the exposure triangle and lens information to annotate example figures with the settings that produced them — see the metadata sections of Basic image processing and ISP. It does not read EXIF for anything it needs to be physically exact, for the reason given above.

[figure fig-exif-dump not built]
Figure 22.12.1. What a camera writes into a file. An annotated exiftool listing of one of the book's own photographs, with the tags color-grouped by what they describe — capture settings (shutter, aperture, ISO), optics (focal length and 35 mm-equivalent, lens model), image (dimensions, color space, the all-important orientation flag), time (DateTimeOriginal vs DateTimeDigitized), GPS, and the opaque MakerNote block — beside a one-line note on which values are exact and which are rounded.