No Exif XP tags using Piexifjs

71 Views Asked by At

I am trying to read EXIF data from JPG file using Piexifjs in React

I have updated the metadata using Zoner - specifically Title = TitleTest; Description = DescriptionTest; Keywords = Keyword1, Keyword2, Keyword3 ... and now I am trying to read them

The output is that XPKeywords do not exist, and neither do any other XP Tag. I have tried looking into all of the piexifjs output data and the only two tags that contain the data I am looking for is

  • 0th/270 (ImageDescription) = "TitleTest"
  • Exif/37510 (UserComment) = "UNICODEDescriptionTest"

but none of the above is XP tags

Output

Using exifTool I can see all of this data ExifTool

and also using image properties in Windows

ImageProps

import piexif from "./piexif";

export function App(props) {
  const fileChangedHandler = (event) => {
    const file = event.target.files[0];

    if (file) {
      var reader = new FileReader();
      reader.onload = function (e) {
        try {
          var exifObj = piexif.load(e.target.result);
          console.log("Exif Data:", exifObj);

          // Check if XPKeywords exist in the 0th IFD
          if (exifObj["0th"] && exifObj["0th"][piexif.ImageIFD.XPKeywords]) {
            const xpKeywords = exifObj["0th"][piexif.ImageIFD.XPKeywords];
            console.log("XPKeywords:", xpKeywords);
          } else {
            console.log("XPKeywords not found in Exif data.");
          }
        } catch (error) {
          console.error("Error reading Exif data:", error);
        }
      };
      reader.readAsDataURL(file);
    }
  };
  return (
    <div className="App">
      <input type="file" onChange={fileChangedHandler} />
    </div>
  );
}
1

There are 1 best solutions below

1
user22794563 On

can i know how you write userComment to jpg? I also want to write UserComment tp jpg by Piexifjs in React,but always failed