exif-component
raw JSON → 1.0.1 verified Sat Apr 25 auth: no javascript deprecated
Client-side EXIF parser for JPEG/TIFF images. Version 1.0.1 is the latest release. This is a fork of ExifReader with a simplified API, designed specifically for the Component package manager (not npm). It extracts metadata tags from an ArrayBuffer input. The package has not been updated since 2014 and targets legacy browser and Node.js environments. For modern usage, consider using the original ExifReader or exifr.
Common errors
error TypeError: exif is not a function ↓
cause Incorrect import style: using named import or ES import syntax on a CommonJS module that exports a single function.
fix
Use const exif = require('exif-component'); instead of import { exif } from 'exif-component'; or import exif from 'exif-component';.
error Error: First argument must be an ArrayBuffer ↓
cause Passing a Node.js Buffer or plain string instead of an ArrayBuffer.
fix
Convert Buffer to ArrayBuffer before calling exif: const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
Warnings
deprecated This package is a fork of ExifReader with a simplified API but has not been updated since 2014. Consider using the original ExifReader or exifr for modern applications. ↓
fix Use exifr (https://www.npmjs.com/package/exifr) or ExifReader (https://www.npmjs.com/package/exifreader) instead.
gotcha This package uses the Component package manager, not npm. Installation via npm will not work as expected. ↓
fix Install using component install component/exif or directly from GitHub. Alternatively, migrate to an npm-published EXIF library.
gotcha The library expects an ArrayBuffer, not a Buffer or Blob. Node.js users must convert Buffer to ArrayBuffer manually. ↓
fix Use buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength) to convert a Node.js Buffer to an ArrayBuffer.
Install
npm install exif-component yarn add exif-component pnpm add exif-component Imports
- exif wrong
import exif from 'exif-component';correctconst exif = require('exif-component'); - exif wrong
import { exif } from 'exif-component';correctconst { exif } = require('exif-component');
Quickstart
const fs = require('fs');
const exif = require('exif-component');
// Read an image file as buffer
const buffer = fs.readFileSync('image.jpg');
// Convert to ArrayBuffer
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
// Parse EXIF
try {
const tags = exif(arrayBuffer);
console.log(JSON.stringify(tags, null, 2));
} catch (err) {
console.error('Failed to parse EXIF:', err.message);
}