I’m developing a simple Chromium extension that reads EXIF data and shows to the user but in the library I’m using (which is Exif.js), I feel like there are things I’m not doing correctly because the output is always an empty string and undefined. Here’s the code:
const img = document.getElementById("someImage");
window.onload = getExif(img);
function getExif(file) {
try {
EXIF.getData(file, function () {
if (file) {
var make = EXIF.getTag(this, "Make");
var model = EXIF.getTag(this, "Model");
var allMetaData = EXIF.pretty(this);
console.log(JSON.stringify(allMetaData, null, 2));
console.log(make, model);
} else {
console.error("EXIF data has not been found or incomplete.");
}
});
} catch (error) {
console.error("Error reading EXIF data", error);
}
}
“make” and “model” always returns an “undefined” from an image I’m using through classical const img = document.getElementById(someImage)
in popup.html as well as allMetaData returning and empty string.
I’ve followed the “Usage” section in the documentation but nothing appears to be fixing this.