MikeKovarik / exifr

📷 The fastest and most versatile JS EXIF reading library.
https://mutiny.cz/exifr/
MIT License
1.04k stars 70 forks source link

Missing/wrong Rating meta? #100

Open KeyboardRage opened 1 year ago

KeyboardRage commented 1 year ago

I'm trying to use this tool to read ratings of images, but there seems to be a big discrepancy I can't figure out where different Exif readers and programs shows different results.

I've attached an image used for the following results:

I am not quite sure which one to go with here, but there seem to be some information differences. I tested on a different computer for both Explorer and Adobe Bridge to try to rule out cache as much as possible, and there are no hidden sidecar files either.

Image used for these results

grasdk commented 7 months ago

@KeyboardRage - better late than never: The difference from the different programs comes from how they merge and prioritize overlapping tags from different exif sections. If you want full control, you should avoid merging.

In your particular case, the answer lies in the fact that there is both an exif-ifd0 rating and an xmp rating:

$ exiftool 207094492-0a102e25-dcb5-4603-8123-f0e6304cdafb.jpg -rating* -g -a -s -G0:1
[EXIF:IFD0]     Rating                          : 1
[EXIF:IFD0]     RatingPercent                   : 1
[XMP:XMP-xmp]   Rating                          : 2
[XMP:XMP-microsoft] RatingPercent               : 1

With exifr, you get this (abbreviated by manually removing all non-rating data):

{
  "xmp": {
    "Rating": 2
  },
  "MicrosoftPhoto": {
    "Rating": 1
  },
  "ifd0": {
    "Rating": 1,
    "RatingPercent": 1
  }
}

These were my exifr options:

        const exifrOptions = {
            tiff: true,
            xmp: true,
            icc: false,
            jfif: false,
            ihdr: true,
            iptc: false,
            exif: true,
            gps: true,
            translateValues: false,
            mergeOutput: false //don't merge output, because things like Microsoft Rating (percent) and xmp.rating will be merged
        };
KeyboardRage commented 7 months ago

@grasdk Hey, yes better than never 😄 Thank you so much for the clarification and examples. Today I learned something new!