media-metadata
A pure JS library to parse EXIF and IPTC metadata out of media files. Currently only JPEG images are supported but I hope to improve on that in the future.
A few other similar projects exist but this one aims to be usable both in node and (when bundled with something like webpack) in a webpage.
Examples
Basic usage is to just pass an ArrayBuffer to the parseBuffer function:
const parseBuffer = ; let buffer = ... // an ArrayBuffer of image datalet metadata = ;
In a webpage you can get an appropriate buffer with a fetch:
const parseBuffer = ; let response = await ;let buffer = response;let metadata = ;
Or from a File:
const parseBuffer = ; let file = ... // a File instancelet reader = ;reader { let buffer = eventtargetresult; let metadata = ;};reader;
Metadata format
The metadata is returned as a JS object with sections for each source of metadata and date inside those. Something like this:
"exif": "ImageDescription": "The description" "xmp": "http://purl.org/dc/elements/1.1/description": "The description"
A fuller example can be seen in the tests.
Dates etc. are not decoded by this module, it is up to you to decode the actual values when needed.