0

I want to get the meta data of an image using PiexifJs but I am not able to and also I am not getting any error

If anyone knows the answer or where I can look this up I would appreciate thanks

<body>
    <input type="file" id="fileInput" onchange="previewMetadata()" accept="image/*">
    <ul id="metadataList"></ul>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/piexifjs/2.0.0-beta.8/piexif.js"></script>
    <script>
      function previewMetadata() {

        const fileInput = document.getElementById("fileInput");
        const file = fileInput.files[0];
        const reader = new FileReader();

        reader.onload = function(e) {
          const exifData = piexif.load(e.target.result);
          const metadataList = document.getElementById("metadataList");
          metadataList.innerHTML = "";

          for (const ifd in exifData) {

            if (ifd === "thumbnail") continue;

            const ifdName = piexif.IFDNames[ifd];
            metadataList.innerHTML += "<li>" + ifdName + "</li>";

            for (const tag in exifData[ifd]) {
              const tagName = piexif.TAGS[ifd][tag]["name"];
              const tagValue = exifData[ifd][tag];
              metadataList.innerHTML += "<li>" + tagName + ": " + tagValue + "</li>";
            }
          }
        };
        reader.readAsDataURL(file);
      }
    </script>
</body>
Wahlstrommm
  • 684
  • 2
  • 7
  • 21

0 Answers0