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.
npm i xmp-js<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.
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` XMPconst 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.
Install npm packages:
npm iProduction build with Rollup.js:
npm run build