Bug 441500 - Negative XMP ratings show as 1
Summary: Negative XMP ratings show as 1
Status: RESOLVED DUPLICATE of bug 367896
Alias: None
Product: digikam
Classification: Applications
Component: Tags-Rating (show other bugs)
Version: 7.3.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-24 19:45 UTC by kdebugs
Modified: 2021-10-26 06:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Sample XMP (7.88 KB, application/xml)
2021-08-25 15:39 UTC, kdebugs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kdebugs 2021-08-24 19:45:54 UTC
When Digikam reads a file with a negative rating in its EXIF/XMP, it treats the rating as a "1" rating.

Darktable marks rejected images with a rating of -1, so I would like Digikam to be compatible.


STEPS TO REPRODUCE
1. Import a file with a negative rating in XMP/EXIF
2. View item Properties in Digikam
3. Filter an album in Digikam with rating 0 selected and "less than or equal to" for the filter criterion

OBSERVED RESULT
2. Rating shows a single star icon
3. No images are shown


EXPECTED RESULT
2. Rating shows -1
3. Images are shown


SOFTWARE/OS VERSIONS
Windows: ?
macOS: ?
Linux/KDE Plasma: Not installed?
(available in About System)
KDE Plasma Version: Not installed?
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

- The XMP sidecar shows: xmp:Rating="-1"
- Darktable's behaviour is consistent with the XMP specification:

  "A user-assigned rating for this file. The value shall be -1 or in the range [0..5], where -1 indicates “rejected” and 0 indicates “unrated”. If xmp:Rating is not present, a value of 0 should be assumed.
  "NOTE Anticipated usage is for a typical “star rating” UI, with the addition of
a notion of rejection."
Comment 1 caulier.gilles 2021-08-25 05:23:46 UTC
can you share a file sample plus side car processed with a -1 rating, please...

Gilles Caulier
Comment 2 Maik Qualmann 2021-08-25 06:03:00 UTC
digiKam does not import a "-1" rating as a "1" rating. The rating will come from another metadata tag, because digiKam knows 5 other possible tags for the rating. Go to the advanced metadata settings and deactivate all metadata tags that are not relevant to you.

The problem is rather programs that only change one metadata tag and leave others unchanged. Problems then inevitably arise with other programs, and there is also a mix of metadata in the images.

When you have made the change, you must also temporarily activate the setting to clean up the database (metadata settings) so that the "1" rating is also deleted when the images are read in again.

If you upload a sample, we need the image + sidecar.

Maik
Comment 3 kdebugs 2021-08-25 15:39:35 UTC
Created attachment 141037 [details]
Sample XMP

I've attached a sample XMP. The original file is a DNG file so too large to attach.

However the bug isn't what I thought it was. It isn't that Digikam maps -1 to 1, it's that Digikam falsely treats -1 as invalid and ignores it completely.

When I did as suggested and turned on database cleanup and checked my advanced metadata settings for ratings, then rescanned, Digikam cleared the rating from the image entirely.

I went digging through the code and found this code responsible for actually reading the rating: https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/metadataengine/dmetadata/dmetadata_labels.cpp#L163-263

This shows that Digikam improperly treats a rating of -1 exactly the same as no rating being found at all.

I also found a "convertRatio" referenced around the codebase that seems to be a map of numbers to stars. The size of this array is 6 items, with the first number corresponding to 0 stars and the last to 5 stars.

I'm not sure what to do about the problem. Should another index be added to convertRatio for negative ratings and the UI updated (maybe with a cross or something for rejected)?

If the contribution would be welcome I think I could take a stab at it.
Comment 4 Maik Qualmann 2021-08-25 20:36:47 UTC
Yes, that is correct, digiKam does not currently support a negative rating. A long time ago I made a patch with basic support for negative ratings. I use a horizontal line through all stars for negative ratings.

I know that the value -1 is described in the standard, personally I don't think it's good for the rating idea.

Maik
Comment 5 Maik Qualmann 2021-10-26 06:10:23 UTC

*** This bug has been marked as a duplicate of bug 367896 ***