exif-js
A dependency-free JavaScript library for reading EXIF and IPTC metadata from images in the browser.
Repository Health
Technical Analysis
Exif.js is a small, standalone JavaScript library that extracts EXIF metadata (camera make/model, exposure settings, orientation, GPS data, timestamps) directly from JPEG and TIFF images inside the browser. It works against an <img> element’s src, a user-selected file from an <input type="file">, or a raw File/Blob object, parsing the binary JPEG marker segments itself via DataView rather than shipping the image to a server.
Beyond the core EXIF standard (v2.2 / JEITA CP-3451), it also reads IPTC caption/copyright fields and can optionally extract embedded XMP data. It has no runtime dependencies, supports CommonJS/AMD/global usage, and ships a hand-written TypeScript declaration file for editor support.
What You Get
EXIF.getData(image, callback)to asynchronously parse EXIF (and IPTC) data from an<img>element, aFile/Blob, or a data/blob/remote URLEXIF.getTag(img, tag)andEXIF.getAllTags(img)for reading individual or all parsed tags off the image object afterwardEXIF.pretty(img)for a human-readable, pretty-printed dump of all extracted tagsEXIF.readFromBinaryFile(file)for parsing EXIF data directly from an already-loaded binary file- Optional XMP metadata extraction via
EXIF.enableXmp() - A bundled TypeScript declaration file (
exif.d.ts) for typed usage
Common Use Cases
- Displaying photo capture details (camera, lens, exposure, date taken) next to a user-uploaded image
- Reading the EXIF
Orientationtag client-side to auto-rotate images before upload or display - Stripping/inspecting metadata in a photo-upload form before sending files to a server
- Building browser-based photo viewers or galleries that surface GPS/location data from images
Under The Hood
Architecture
Exif.js is a single self-invoking module that exports one EXIF object (via CommonJS, AMD, or the global scope). Public entry points like EXIF.getData funnel into getImageData, which branches on the kind of input it receives — a data URI, a blob URL, a remote image URL, or a File/Blob — and normalizes each into an ArrayBuffer before handing it to a shared handleBinaryFile callback. From there, byte-level parsers (findEXIFinJPEG, findIPTCinJPEG, findXMPinJPEG, readTags, readTagValue) walk the JPEG’s marker segments directly via DataView to locate and decode the EXIF/IPTC/XMP blocks. The design is monolithic (everything lives in one file with no internal module boundaries or dependency injection), but it does keep async I/O concerns cleanly separate from the binary-parsing logic; because tag tables and parsing routines are directly attached to the exported global object, any change to the internal tag dictionaries or parsing flow ripples straight through to consumers.
Tech Stack
Zero runtime dependencies and no build step — the library is hand-written ES5 (var, function expressions) distributed as a single exif.js file, using only native browser APIs (DataView, ArrayBuffer, FileReader, XMLHttpRequest). It exposes a UMD-style export path that detects CommonJS/AMD/global environments, and ships a manually maintained exif.d.ts for TypeScript consumers. devDependencies are limited to bower and mversion, used only for packaging/versioning, not building or testing.
Code Quality
No test files or test framework exist anywhere in the repository, and there is no CI configuration. Error handling is minimal — a single raw throw "Could not load image" string throw is the only explicit error path, and the README itself documents a known silent-failure mode (calling getData before the image finishes loading fails without any signal). Naming is descriptive for tag constants but function-level documentation is sparse, there is no linter or formatter configuration, and the TypeScript types are hand-maintained separately from the implementation rather than derived from it, leaving them prone to drifting out of sync.
What Makes It Unique
Its value is doing real binary EXIF/IPTC/XMP parsing entirely client-side, byte-by-byte, against the actual EXIF 2.2 specification, with no server round-trip and no external dependencies. The parsing technique itself — scanning JPEG marker segments with DataView — is a standard, well-understood approach for this domain rather than a novel algorithm, but implementing it dependency-free and fully in-browser is what has kept this small library broadly used for over a decade.