DEV Community

Cover image for Working with Image Metadata: EXIF, IPTC, and XMP for Developers
GeoImageTagger
GeoImageTagger

Posted on Originally published at geoimagetagger.com

Working with Image Metadata: EXIF, IPTC, and XMP for Developers

Image metadata is one of those topics developers encounter when they build media upload pipelines, CMS integrations, or asset management systems. Understanding the three metadata standards — and where they differ — saves time and prevents bugs.

The Three Standards

EXIF

EXIF stores technical capture data in the APP1 marker of JPEG files. It is automatically written by cameras and phones.

Key fields: Make, Model, LensModel, FNumber, ExposureTime, ISO, FocalLength, GPSLatitude, GPSLongitude, DateTimeOriginal, ImageWidth, ImageHeight, Orientation.

EXIF was designed for JPEG and TIFF. It works in HEIC but does not natively exist in PNG or WebP (those formats use XMP instead).

IPTC

IPTC metadata is stored in the IPTC-IIM segment of JPEG files. It covers editorial fields that humans add: Copyright, Creator, Headline, Keywords, Caption-Abstract, City, Province-State, Country-PrimaryLocationName.

Google reads IPTC copyright and creator fields for image attribution in Google Images. This is the most SEO-relevant metadata standard.

XMP

XMP is embedded as XML, typically in a <x:xmpmeta> block. It works across almost all image formats including PNG and WebP, which is why many modern tools write to XMP rather than IPTC.

Key fields: XMP:Title, XMP:Description, XMP:Subject (keywords), XMP:Creator, XMP:Rights, XMP:CreatorTool, XMP:Rating, XMP:Label.

Reading Metadata

ExifTool (CLI)

ExifTool is the reference implementation for reading and writing metadata:

# All metadata
exiftool -json photo.jpg

# Specific namespaces
exiftool -EXIF:all photo.jpg
exiftool -IPTC:all photo.jpg
exiftool -XMP:all photo.jpg

# Structured output
exiftool -s -G1 photo.jpg
Enter fullscreen mode Exit fullscreen mode

Python

from PIL import Image
from PIL.ExifTags import TAGS

img = Image.open("photo.jpg")
exif_data = img._getexif()

if exif_data:
    for tag_id, value in exif_data.items():
        tag = TAGS.get(tag_id, tag_id)
        print(f"{tag}: {value}")
Enter fullscreen mode Exit fullscreen mode

For write operations, piexif gives more control:

import piexif

exif_dict = piexif.load("photo.jpg")

# Read GPS
gps = exif_dict.get("GPS", {})
print(f"Latitude: {gps.get(piexif.GPSIFD.GPSLatitude)}")

# Write description
exif_dict["0th"][piexif.ImageIFD.ImageDescription] = b"Updated description"
exif_bytes = piexif.dump(exif_dict)
piexif.insert(exif_bytes, "photo.jpg")
Enter fullscreen mode Exit fullscreen mode

Browser-Based

For quick inspection without CLI tools, the Metadata Viewer on GeoImageTagger extracts all metadata client-side using JavaScript. The processing runs entirely in the browser — useful when you cannot install software or need to check a file quickly.

Writing Metadata

ExifTool

# Set IPTC copyright
exiftool -IPTC:Copyright="© 2026 Company Name" photo.jpg

# Set GPS
exiftool -GPSLatitude=48.8584 -GPSLongitude=2.2945 \
         -GPSLatitudeRef=N -GPSLongitudeRef=E photo.jpg

# Set XMP keywords
exiftool -XMP:Subject="architecture,paris,landmark" photo.jpg

# Batch process
exiftool -IPTC:Copyright="© 2026 Company" -overwrite_original *.jpg
Enter fullscreen mode Exit fullscreen mode

Online Editor

The Metadata Editor on GeoImageTagger provides a notepad-style UI for editing EXIF, IPTC, and XMP fields. It uses ExifTool on the server side to write metadata without re-encoding the image. Upload up to 5 images, edit fields across 8 sections (Content, Location, Camera, Exposure, Date/Time, Author/Copyright, IPTC, XMP), and download the results.

The key implementation detail: metadata bytes are modified directly in the file — no pixel re-encoding occurs, so there is zero quality degradation.

Common Gotchas

  1. IPTC-IIM vs XMP mapping: IPTC-IIM keywords are stored as IPTC:Keywords. XMP keywords are stored as XMP:Subject. They should be kept in sync. Some tools write to one but not the other.

  2. HEIC and WebP lack IPTC-IIM support. These formats rely on XMP for editorial metadata. If you read IPTC data from a HEIC file and get nothing, check the XMP equivalent fields.

  3. GPS coordinate formats: EXIF stores GPS as degrees/minutes/seconds (DMS) with separate reference fields (GPSLatitudeRef: N). Many APIs expect decimal degrees. Conversion: decimal = degrees + minutes/60 + seconds/3600.

  4. Orientation tag: EXIF tag 0x0112 controls how the image should be rotated for display. Never modify this during metadata editing, or images will display sideways.

  5. Metadata stripping during compression: Most image compression tools strip all metadata by default. If you need metadata preserved after compression, use tools that explicitly support it. GeoImageTagger's Image Compressor preserves metadata by default with server-side verification.

Key Takeaways

  • EXIF = camera data (auto-generated), IPTC = editorial data (human-added), XMP = extensible data (both)
  • Google reads IPTC for image attribution — it is the most SEO-relevant standard
  • Always verify metadata after editing — field-level before/after comparison catches errors
  • HEIC and WebP do not support IPTC-IIM; use XMP for those formats
  • Never re-encode pixel data when editing metadata; modify metadata bytes only

Full guide with comparison tables and FAQ: How to Read and Edit Image Metadata

Top comments (0)