Bug 446183

Summary: Star Rating for Picture is not read from File's metadata or read incorrectly
Product: [Applications] digikam Reporter: Tom <tom33st>
Component: Tags-RatingAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles, metzpinguin
Priority: NOR    
Version: 7.4.0   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In: 7.4.0
Sentry Crash Report:
Attachments: Screenshot 1 - Missing star rating in table view
Screenshot 2 - Missing star rating in thumbnail view
Screenshot 3 - Metadata->Exiftool information on Rating
Screenshot 4 - Metadata->Exiftool wrong / double rating information shown
Screenshot 5 - Metadata->Exiftool not in line with rating shown in thumbnail after change

Description Tom 2021-11-28 06:44:28 UTC
Created attachment 144016 [details]
Screenshot 1 - Missing star rating in table view

Sample Files (uploaded to dropbox due to large size): 
a) D81_9520.jpg -> No xmp sidecar file, all metadata resides in the .jpg File. Star Rating NOT read.
https://www.dropbox.com/s/oxsmbbcby6w0zhp/D81_9520.jpg?dl=0

b) D82_1044.jpg -> Also No xmp sidecar file. Star rating shown in DigiKam is wrong (shows 4, should be 3) / Metadata view shows two different star ratings
https://www.dropbox.com/s/92shc59a9vwpedk/D82_1044.jpg?dl=0


a) Star rating not read from jpg-File D81_9520.jpg
In Thumbnail, Preview and Table-View, DigiKam does not show a Star Rating for this jpg. 
See attached screenshots sc01, sc02, sc03.png.
In the Metadata/ExifTool Tab is shows in section XMP a Rating (3). For the same File Apple Aperture / Apple Preview / Excire Photo shows a 3 star rating.
For the correspondig nef File (D81_9520.NEF) which also has the Star-Rating in the XMP section (NO sidecar file) the star rating is shown correctly.


Running exiftool -g -Rating D81_9520.jpg results in:

---- XMP ----
Rating                          : 3


b) Wrong star rating shown (D82_1044.jpg)
Thumbnail, Preview and Table-View show 4 stars for this one, whereas it only has a 3 star rating. Metadata/Exiftool shows Rating in the EXIF-Section (4) and Rating in XMP Secion (3).
See attaches sc10.png
Also here, for the corresponding .nef file the star rating is shown correctly.
Running exiftool on the Shell results in:

exiftool -g -Rating D82_1044.jpg 
---- XMP ----
Rating                          : 3


STEPS TO REPRODUCE
1. Create Album and scan with the linked jpg files
2. check star rating in Tumbnails, Preview or List view
3. Check against exiftools output in shell

OBSERVED RESULT
No or wrong star rating shown.

EXPECTED RESULT
Same star rating as shown in exiftool when run on the shell outside of DigiKam.

SOFTWARE/OS VERSIONS
macOS: BigSur 11.6

ADDITIONAL INFORMATION
Comment 1 Tom 2021-11-28 06:45:22 UTC
Created attachment 144017 [details]
Screenshot 2 - Missing star rating in thumbnail view
Comment 2 Tom 2021-11-28 06:46:02 UTC
Created attachment 144018 [details]
Screenshot 3 - Metadata->Exiftool information on Rating
Comment 3 Tom 2021-11-28 06:47:09 UTC
Created attachment 144019 [details]
Screenshot 4 - Metadata->Exiftool wrong / double rating information shown
Comment 4 Maik Qualmann 2021-11-28 07:19:08 UTC
Which program were used to process the images? Exiv2 cannot read the XMP metadata. We do not use Exiftool for this task to load the information into the database.

digikam.metaengine: Exiv2 ( 3 ) :  XMP Toolkit error 201: Error in XMLValidator
digikam.metaengine: Exiv2 ( 2 ) :  Failed to decode XMP metadata.

Maik
Comment 5 Tom 2021-11-28 07:34:58 UTC
Created attachment 144021 [details]
Screenshot 5 - Metadata->Exiftool not in line with rating shown in thumbnail after change

Something else that appears wired to me: When I change the star rating using the mouse in the stars at the bottom of the thumbnail - the star rating on the Metadata-Exiftools does not change.
Comment 6 Tom 2021-11-28 07:36:04 UTC
(In reply to Maik Qualmann from comment #4)
> Which program were used to process the images? Exiv2 cannot read the XMP
> metadata. We do not use Exiftool for this task to load the information into
> the database.
> 
> digikam.metaengine: Exiv2 ( 3 ) :  XMP Toolkit error 201: Error in
> XMLValidator
> digikam.metaengine: Exiv2 ( 2 ) :  Failed to decode XMP metadata.
> 
> Maik

Good morning Maik,
also an early bird (on a Sunday) :-)

D81_9520.jpg - Originally the file was done with DxO PhotoLab.
I now went into Apple Aperture and did a Ć¢write MetadataĆ¢ to File - checked that the jpg file was updated. In DigiKam I reloaded the Metadata (for the file D81_9520.jpg) - no change in DigiKam. Still no star rating shown.

D82_1044.jpg - also done in DxO PhotoLab - a bit newer Version.

But: I have tons of other pictures also done with the same versions of DxO and there star ratings are shown correctly.

Best, Tom
Comment 7 Maik Qualmann 2021-11-28 07:39:38 UTC
The XMP metadata in the images are defective, yes Exiftool can read them but we use Exiv2 to write / read.

Maik
Comment 8 caulier.gilles 2021-11-28 07:42:04 UTC
Tom,

I recommend to report this problem to Exiv2 team from Github. Don't forget to precise the program name used to assign the stars, the operating system version, and to attach images files to reproduce the dysfunction with the Exiv2 CLI tool.

https://github.com/Exiv2/exiv2/issues

Best

Gilles Caulier
Comment 9 Maik Qualmann 2021-11-28 07:53:01 UTC
You should report the problem to Exiv2 so that it "becomes more tolerant" when it comes to decoding the XMP metadata.
You can repair the metadata with the following command, but as you can see, Exiftool will also issue a warning:

exiftool D81_9520.jpg -xmp:all= -tagsfromfile @ -xmp:all -overwrite_original

Warning: [minor] Bad NikonScanIFD directory - D81_9520.jpg
1 image files updated

Maik
Comment 10 Maik Qualmann 2021-11-28 09:22:23 UTC
Exiftool can validate the metadata for correctness, here is the output for your images:

exiftool -error -warning -validate -a D81_9520.jpg 
Warning                         : [minor] Bad NikonScanIFD directory
Warning                         : [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto
Warning                         : [minor] Ignored empty rdf:Bag list for dc:subject
Warning                         : [minor] IPTC By-line too long (36 bytes; should be 32 max)
Warning                         : [minor] IPTC TimeCreated too short (6 bytes; should be 11)
Warning                         : [minor] IPTC DigitalCreationTime too short (6 bytes; should be 11)
Validate                        : 6 Warnings (all minor)

exiftool -error -warning -validate -a D82_1044.jpg 
Warning                         : [minor] Non-standard IFD0 tag 0x4746 Rating
Warning                         : [minor] Bad NikonScanIFD directory
Warning                         : [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto
Warning                         : [minor] Ignored empty rdf:Bag list for dc:subject
Warning                         : [minor] IPTC By-line too long (36 bytes; should be 32 max)
Warning                         : [minor] IPTC TimeCreated too short (6 bytes; should be 11)
Warning                         : [minor] IPTC DigitalCreationTime too short (6 bytes; should be 11)
Validate                        : 7 Warnings (all minor)

Maik
Comment 11 Tom 2021-11-28 10:23:47 UTC
(In reply to Maik Qualmann from comment #10)
> Exiftool can validate the metadata for correctness, here is the output for
> your images:
> 
> exiftool -error -warning -validate -a D81_9520.jpg 
> Warning                         : [minor] Bad NikonScanIFD directory
> Warning                         : [minor] Fixed incorrect URI for
> xmlns:MicrosoftPhoto
> Warning                         : [minor] Ignored empty rdf:Bag list for
> dc:subject
> Warning                         : [minor] IPTC By-line too long (36 bytes;
> should be 32 max)
> Warning                         : [minor] IPTC TimeCreated too short (6
> bytes; should be 11)
> Warning                         : [minor] IPTC DigitalCreationTime too short
> (6 bytes; should be 11)
> Validate                        : 6 Warnings (all minor)
> 
> exiftool -error -warning -validate -a D82_1044.jpg 
> Warning                         : [minor] Non-standard IFD0 tag 0x4746 Rating
> Warning                         : [minor] Bad NikonScanIFD directory
> Warning                         : [minor] Fixed incorrect URI for
> xmlns:MicrosoftPhoto
> Warning                         : [minor] Ignored empty rdf:Bag list for
> dc:subject
> Warning                         : [minor] IPTC By-line too long (36 bytes;
> should be 32 max)
> Warning                         : [minor] IPTC TimeCreated too short (6
> bytes; should be 11)
> Warning                         : [minor] IPTC DigitalCreationTime too short
> (6 bytes; should be 11)
> Validate                        : 7 Warnings (all minor)
> 
> Maik

Tanks a lot Maik. I did some further investigations:
After repairing the metadata with exiftools as you proposed and re-reading the metadata from the image it is shown correctly in digikam. 
Then I updated the star rating in Apple Aperture and wrote the change from the DB to the jpg. Again, after re-reading the metadata information, digikam is not updating the star informtion according to the changes done in aperture, whereas all other image software packages I could test on show the changed star information. I assume this might be a challenge for other people with large repositories which are currently swithching to digikam (which is an AMAZING tool!) as well. I will try to open a request with Exiv2.
Comment 12 Tom 2021-11-28 10:43:28 UTC
(In reply to caulier.gilles from comment #8)
> Tom,
> 
> I recommend to report this problem to Exiv2 team from Github. Don't forget
> to precise the program name used to assign the stars, the operating system
> version, and to attach images files to reproduce the dysfunction with the
> Exiv2 CLI tool.
> 
> https://github.com/Exiv2/exiv2/issues
> 
> Best
> 
> Gilles Caulier

Dear Gilles,
thanks for your hint about repairing the file. I tried - see comment below to Maik.
I opened a feature request with the exif2 team. https://github.com/Exiv2/exiv2/issues/2005
Comment 13 Maik Qualmann 2021-11-28 10:50:14 UTC
Well, I don't know what metadata information for rating the Apple Aperture program changes. You have to find out and make the appropriate in the digiKam setting for metadata in the advanced settings. By moving the rating tag to the beginning of the list. digiKam searches for rating tags in the order of the list. Otherwise send a changed image from Apple Aperture.

Maik
Comment 14 Maik Qualmann 2021-11-28 16:34:15 UTC
Since you set a rating with digiKam, digiKam's metadata entry for the rating now also exists. Since Apple Aperture does not change the digiKam metadata entry for rating, digiKam does not recognize a changed rating. Move the digiKam rating tag from the top to the bottom in the advanced metadata settings.

Maik
Comment 15 Maik Qualmann 2021-11-28 16:37:58 UTC
Ok, since the problem exists in the Adobe SDK, neither Exiv2 nor digiKam can do anything here. We already have bug reports with wishes to write or read metdata with Exiftool in special problem cases. I would close the bug here for the time being ... 

Maik
Comment 16 Tom 2021-11-30 05:31:08 UTC
Sure - I understand - please close the bug.
Thanks for your help!

Best, Tom