Skip to content

Latest commit

 

History

History
77 lines (59 loc) · 1.73 KB

README.md

File metadata and controls

77 lines (59 loc) · 1.73 KB

xmp-js logo

XMP Parser

Super-light and fast JavaScript lib to read and parse XMP (Extensible Metadata Platform) metadata (such as Title, Description etc.) from JPEG files written, for example, by Adobe Photoshop and Adobe Lightroom.

Install

npm i xmp-js

Usage

In Browser

<script src="dist/xmp.iife.min.js"></script>
<script>
    let input = document.querySelector("input[type='file']");
    input.addEventListener("change", (e) => {
        let file = e.target.files[0];
        var reader = new FileReader();
        reader.onload = e => {
            let xmp = new XMP(e.target.result),
                raw = xmp.find(),
                parsed = xmp.parse();
            // do what you want with `raw` or `parsed` XMP
        };
        reader.readAsDataURL(file);
    })
</script>

See demo.html for example.

As ES6 Module

import XMP from "xmp-js";
let xmp = new XMP(< ArrayBuffer or dataURI >),
    raw = xmp.find(),
    parsed = xmp.parse();
// do what you want with `raw` or `parsed` XMP

In Node.js

const XMP = require("xmp-js"),
    fs = require("fs");

fs.readFile(< path to JPEG file >, (err, file) => {
    if (err) {
        console.error("Error while reading the file", err);
    }

    let xmp = new XMP(file),
        raw = xmp.find(),
        parsed = xmp.parse();
    // do what you want with `raw` or `parsed` XMP
});

See demo.js for example.

Build

Install npm packages:

npm i

Production build with Rollup.js:

npm run build