0.0.5 • Published 4 years ago

xmp-js v0.0.5

Weekly downloads
43
License
MIT
Repository
github
Last release
4 years ago

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
0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago