Bug 495646 - ICC metadata lost
Summary: ICC metadata lost
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Exif (show other bugs)
Version: 8.4.0
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-31 16:22 UTC by Caro
Modified: 2024-11-05 21:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 8.5.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Caro 2024-10-31 16:22:27 UTC
SUMMARY
When adding a tag in Digikam to a picture, the ICC tags are deleted

STEPS TO REPRODUCE
1. Navigate to the attached picture
2. Add a tag
3. Check the metadata: the ICC tags are not anymore here

OBSERVED RESULT
The ICC tags have disappeared

EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Caro 2024-10-31 16:26:22 UTC
The picture is too big to upload, here is a wetransfer link https://we.tl/t-3HlcL9kVYJ
Comment 2 Maik Qualmann 2024-10-31 16:32:03 UTC
The sample image has no ICC profile. To reproduce it we need the image before you add tags.

Maik
Comment 3 Maik Qualmann 2024-10-31 16:38:43 UTC
The image has an editing history from both Lightroom and Gimp. The ICC profile may have already been lost there.

Maik
Comment 4 Caro 2024-11-01 16:58:25 UTC
Hi Maik,

I well see the ICC profile, using Exiftool command:  exiftool -G1 -a C:\Users\carop\Downloads\IMG_1897.jpg

[ICC-header]    Profile CMM Type                : Unknown (KCMS)
[ICC-header]    Profile Version                 : 2.1.0
[ICC-header]    Profile Class                   : Display Device Profile
[ICC-header]    Color Space Data                : RGB
[ICC-header]    Profile Connection Space        : XYZ
[ICC-header]    Profile Date Time               : 1998:12:01 18:58:21
[ICC-header]    Profile File Signature          : acsp
[ICC-header]    Primary Platform                : Microsoft Corporation
[ICC-header]    CMM Flags                       : Not Embedded, Independent
[ICC-header]    Device Manufacturer             : Kodak
[ICC-header]    Device Model                    : ROMM
[ICC-header]    Device Attributes               : Reflective, Glossy, Positive, Color
[ICC-header]    Rendering Intent                : Perceptual
[ICC-header]    Connection Space Illuminant     : 0.9642 1 0.82487
[ICC-header]    Profile Creator                 : Kodak
[ICC-header]    Profile ID                      : 0
[ICC_Profile]   Profile Copyright               : Copyright (c) Eastman Kodak Company, 1999, all rights reserved.
[ICC_Profile]   Profile Description             : ProPhoto RGB
[ICC_Profile]   Media White Point               : 0.9642 1 0.82489
[ICC_Profile]   Red Tone Reproduction Curve     : (Binary data 14 bytes, use -b option to extract)
[ICC_Profile]   Green Tone Reproduction Curve   : (Binary data 14 bytes, use -b option to extract)
[ICC_Profile]   Blue Tone Reproduction Curve    : (Binary data 14 bytes, use -b option to extract)
[ICC_Profile]   Red Matrix Column               : 0.79767 0.28804 0
[ICC_Profile]   Green Matrix Column             : 0.13519 0.71188 0
[ICC_Profile]   Blue Matrix Column              : 0.03134 9e-005 0.82491
[ICC_Profile]   Device Mfg Desc                 : KODAK
[ICC_Profile]   Device Model Desc               : Reference Output Medium Metric(ROMM)
[ICC_Profile]   Make And Model                  : (Binary data 40 bytes, use -b option to extract)

Or do I miss anything ?

Nice day,

Caro
Comment 5 Maik Qualmann 2024-11-01 20:37:40 UTC
Ok, we have a new option in digiKam-8.5.0 to read the metadata with ExifTool. With your image the profile is not imported into the internal EXV container, so I didn't see any profile.

But in standard mode with Exiv2 the profile is there and is not lost if Exiv2 is enabled to write. If writing with ExifTool is enabled, the profile is deleted.

So the problem is when writing with ExifTool (or reading) is enabled. For some reason ExifTool is not importing the profile from the EXV container into the image.

But the problem does not occur with other images here.

We need to investigate it.

Maik
Comment 6 Maik Qualmann 2024-11-02 07:39:46 UTC
Git commit b44d94bd911621d2035c53ba48cfa8a68fad24e2 by Maik Qualmann.
Committed on 02/11/2024 at 07:39.
Pushed by mqualmann into branch 'master'.

implement reading and writing of image ICC profiles with Exiv2
FIXED-IN: 8.5.0

M  +1    -1    NEWS
M  +16   -17   core/libs/metadataengine/dmetadata/dmetadata_exif.cpp
M  +6    -2    core/libs/metadataengine/engine/metaengine.cpp
M  +10   -0    core/libs/metadataengine/engine/metaengine.h
M  +2    -0    core/libs/metadataengine/engine/metaengine_data_p.cpp
M  +2    -0    core/libs/metadataengine/engine/metaengine_data_p.h
M  +13   -4    core/libs/metadataengine/engine/metaengine_fileio.cpp
M  +58   -1    core/libs/metadataengine/engine/metaengine_item.cpp
M  +17   -0    core/libs/metadataengine/engine/metaengine_p.cpp
M  +2    -0    core/libs/metadataengine/engine/metaengine_p.h
M  +1    -0    core/libs/metadataengine/exiftool/exiftoolparser_command.cpp

https://invent.kde.org/graphics/digikam/-/commit/b44d94bd911621d2035c53ba48cfa8a68fad24e2
Comment 7 Maik Qualmann 2024-11-02 07:44:03 UTC
Short explanation: The color profile in your image is only in an Exif tag. This is an unsafe method for ExifTool, so ExifTool always converts it to an image ICC profile and deletes the Exif tag. Up until now, we have only read image ICC profiles via our image loader. Now we can do it directly via Exiv2 and thus also in an EXV container for ExifTool.

Maik
Comment 8 Maik Qualmann 2024-11-02 14:32:11 UTC
Git commit a6ac55851d88f6287e425dbd502fe6cb62e6ac5f by Maik Qualmann.
Committed on 02/11/2024 at 14:31.
Pushed by mqualmann into branch 'master'.

restore old behavior for writing ICC profile with Exiv2

M  +19   -5    core/libs/metadataengine/dmetadata/dmetadata_exif.cpp
M  +26   -10   core/libs/metadataengine/engine/metaengine_p.cpp
M  +1    -0    core/libs/metadataengine/exiftool/exiftoolparser_command.cpp

https://invent.kde.org/graphics/digikam/-/commit/a6ac55851d88f6287e425dbd502fe6cb62e6ac5f
Comment 9 Caro 2024-11-05 20:24:41 UTC
Thanks for checking !

One question from my side: when I update the pictures directly with exiftool, via command line, the ICC profile is well preserved. It only disappears when tagging the picture via Digikam. 

I'm wondering then about your feedback: "So the problem is when writing with ExifTool (or reading) is enabled. For some reason ExifTool is not importing the profile from the EXV container into the image."

Out of curiosity, is Digikam rewriting the entire set of data, when adding a new tag to a picture ? While, when executing exiftool commands via command line, only the tags in the command line are adjusted ?
Comment 10 Maik Qualmann 2024-11-05 21:33:46 UTC
The metadata set is always rewritten. Even if you "only" change a tag directly with ExifTool. There is also an answer to this in the ExifTool FAQ. ExifTool / Exiv2 always rewrites all metadata, there is no other way, pointers to the next metadata block must be updated, etc.
At digiKam there is currently a special feature, we work with ExifTool via an EXV container (metadata without image data).

This is how it works if you have activated reading and writing with ExifTool:

ExifTool -> EXV -> processed with Exiv2 -> EXV -> ExifTool

In your image, some program has written the ICC profile into an EXIF ​​tag.
This is bad behavior for ExifTool and is generally automatically "repaired" when ExifTool changes metadata.
The profile is written to the correct location.
You won't notice this because digiKam basically supports both ICC metadata locations.

How does digiKam-8.5.0 behave with your image?
Writing with Exiv2->ICC profile remains in the EXIF ​​metadata.
Writing with ExifTool->EXIF tag is removed and profile in the correct location.

Maik