Bug 432265

Summary: No error message when Digikam fails to read XMP metadata from image file
Product: [Applications] digikam Reporter: José Oliver-Didier <jose_oliver>
Component: Metadata-ExifToolAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: caulier.gilles, metzpinguin
Priority: NOR    
Version: 7.1.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In: 8.0.0
Sentry Crash Report:
Attachments: Test files
DebugView log

Description José Oliver-Didier 2021-01-28 23:25:54 UTC
Created attachment 135275 [details]
Test files

SUMMARY
No error message is displayed when XMP is failed to be read from image file. XMP

STEPS TO REPRODUCE
1. Open and example files to Digikam album contained in WPG_XMP.zip
2. Making sure all XMP tags are enabled in Settings | Configure digikam | Metadata | XMP, click on "Reread metadata from File"
3. Click on files and view XMP metadata in the Metadata tab (located on the tab on the right and selecting XMP)

OBSERVED RESULT
- For Readable_XMP.jpg - data is displayed on XMP Metadata tab.
- For Unreadable_XMP.jpg - no data is displayed on XMP Metadata tab, XMP data view is blank. The file contains XMP metadata.

EXPECTED RESULT
- For cases where there is an error reading metadata, notify/warn user with an error message displayed in the pane. Example: "Invalid XMP data was found in file".

SOFTWARE/OS VERSIONS
Windows: Windows 10

ADDITIONAL INFORMATION
- In this particular case, the issue pertains to how the XMP was written. In a sense, it is valid XMP but it is very convoluted. The issue is described in the exiv2 issue reported here - https://dev.exiv2.org/issues/0001284
- As described in the bug, at one point it would lead to a crash of Digikam.
- The issue is quite annoying for users of the now un-supported Windows Photo Gallery. Exiftool is able to read the xmp. A way to correct the convoluted XMP by having it being re-constructed using the exiftool command:

exiftool Unreadable_XMP.jpg -xmp:all= -tagsfromfile @ -xmp:all

- I do not expect that Digikam correct the convoluted XMP. Should indicate that there is a problem reading the data and an alternative is to have it overwritten.
- Exiv2 returns "Error: XMP Toolkit error 101: Schema namespace URI and prefix mismatch".
Comment 1 Maik Qualmann 2021-01-29 06:50:46 UTC
There is no relapse from XMP sidecar to image metadata. The XMP sidecar metadata is always mixed with the image metadata. The XMP sidecars have a higher priority. A tag that is present in the image but not in the XMP is then not imported, etc. This behavior has proven itself over many years.

Maik
Comment 2 Maik Qualmann 2021-01-29 07:09:31 UTC
Oh, it's about the XMP files in the image. I don't think we will flood a window or the the system message bar for every error message that Exiv2 displays. That would be too much messages.

Maik
Comment 3 José Oliver-Didier 2021-07-07 15:16:55 UTC
Adding for reference (may be of help to someone) a link to a forum post from the Exiftool Forums in which a method for detecting image files with such a condition and for correcting them.

https://exiftool.org/forum/index.php?topic=12367.msg66881
Comment 4 José Oliver-Didier 2022-02-01 07:31:18 UTC
Created attachment 146120 [details]
DebugView log

Seems Digikam can detect this condition when reading metadata from file (ref attached log):

[5476] digikam.metaengine: Exiv2 ( 3 ) :  XMP Toolkit error 101: Schema namespace URI and prefix mismatch
[5476] digikam.metaengine: Exiv2 ( 2 ) :  Failed to decode XMP metadata.

Exiftool can read the XMP ok. Could Exiftool be used instead to obtain the main XMP values which Digikam uses such as captions, tags, and face regions?
Comment 5 Maik Qualmann 2022-02-01 07:44:32 UTC
One should understand that the Adobe XMP SDK reports this error and cannot decode the XMP metadata. So the metadata is definitely defective or created incorrectly. The ExifTool can read it is because it has its own parser for the metadata that ignores errors. However, you will have problems with the image in most programs, since they use the Adobe XMP SDK.

Maik
Comment 6 caulier.gilles 2022-02-01 07:46:18 UTC
Yes, of course ExifTool can be used as well, and it's planed for specific tasks.

Look the grouped bug entries from Metadata-ExifTool component:

https://bugs.kde.org/buglist.cgi?component=Metadata-ExifTool&list_id=1971501&product=digikam&resolution=---

Gilles caulier
Comment 7 Maik Qualmann 2022-04-24 15:03:06 UTC
Git commit 802d92a3ec46e2ca1b60aa0e2e9bdb8516d4f041 by Maik Qualmann.
Committed on 24/04/2022 at 14:58.
Pushed by mqualmann into branch 'master'.

add read Exiv2 warnings and errors
to then read the metadata with ExifTool
Related: bug 452567, bug 450117, bug 446363, bug 449637

M  +6    -0    core/libs/metadataengine/engine/metaengine_fileio.cpp
M  +8    -0    core/libs/metadataengine/engine/metaengine_p.cpp
M  +1    -0    core/libs/metadataengine/engine/metaengine_p.h

https://invent.kde.org/graphics/digikam/commit/802d92a3ec46e2ca1b60aa0e2e9bdb8516d4f041
Comment 8 Maik Qualmann 2022-10-01 06:27:26 UTC
The test files work fine in digiKam-8.0.0, when an error or warning occurs in Exiv2, ExifTool is automatically used to read the metadata.

Maik