Bug 305823 - digiKam writes to Samsung RAW files with ExifTool.
Summary: digiKam writes to Samsung RAW files with ExifTool.
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-ExifTool (show other bugs)
Version: 2.8.0
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-26 13:52 UTC by xstej70
Modified: 2022-04-08 05:27 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.0.0


Attachments
patchfile (474 bytes, patch)
2012-08-31 18:39 UTC, xstej70
Details

Note You need to log in before you can comment on or make changes to this bug.
Description xstej70 2012-08-26 13:52:10 UTC
I noticed that Digikam writes metadata to Samsung SRW (RAW) files even though I have the option to write to RAWs unchecked.
Canon CR2 and DNG files are handled as expected (XMP sidecar).
It seems that SRW files are not recognized as RAW. 

Reproducible: Always

Steps to Reproduce:
1. Import a SRW file
2. Change metadata or assign a tag
3. Check source folder for XMP sidecar existance or use exiftool to check for updated metadata directly in the SRW
Actual Results:  
Metadata is written directly to the RAW file which is thus altered (unwanted behaviour).

Expected Results:  
Have the changes written to a XMP sidecar file.
Comment 1 caulier.gilles 2012-08-26 14:24:03 UTC
It can depend of which Exiv2 or/and libkexiv2 version you use. Please go to Help/Components Info and copy & paste the contents here...

Gilles Caulier
Comment 2 xstej70 2012-08-27 18:10:56 UTC
Hello Gilles,
I am using exif2 v. 0.23 and libkexiv2 2.3.0.
I don't know if it is related, but sometimes thumbnail-view filters misbehaved in the past. Selecting "no RAW" files would still show SOME SRW files...
Comment 3 caulier.gilles 2012-08-27 18:22:16 UTC
can you turn on KEXIV2, KDCRAW, and digiKam debug spaces into kdebugdialog and run digikam into a console. Process tage changes to a Samsung raw file and copy and paste here all trace relevant from the console...

Gilles Caulier
Comment 4 xstej70 2012-08-29 07:53:57 UTC
Here are the relevant parts. First case is a SRW file, the second is a CR2 file.

digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::getXmpTagStringSeq: XMP String Seq ( Xmp.digiKam.TagsList ):  ("Maya")
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::setIptcKeywords: /home/jarda-wien/temp/exiftool/sam_3987.srw  ==> Iptc Keywords:  Maya,veverka
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: KExiv2::metadataWritingMode 3
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: Will write Metadata to file "sam_3987.srw"
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::KExiv2Priv::saveToFile: File Extension:  "srw"  is supported for writing mode
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: Metadata for file "sam_3987.srw" written to file.


digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::getXmpTagStringSeq: XMP String Seq ( Xmp.digiKam.TagsList ):  ("Maya")
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::setIptcKeywords: /home/jarda-wien/temp/exiftool/casper_IMG_1392.CR2  ==> Iptc Keywords:  Maya,veverka
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: KExiv2::metadataWritingMode 3
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: Will write Metadata to file "casper_IMG_1392.CR2"
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::KExiv2Priv::saveToFile: "casper_IMG_1392.CR2" is TIFF based RAW file not yet supported. Metadata not saved.
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: Metadata for file "casper_IMG_1392.CR2" written to file.
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: Will write XMP sidecar for file "casper_IMG_1392.CR2"
digikam(4063)/KEXIV2 KExiv2Iface::KExiv2::save: Metadata for file ' "casper_IMG_1392.CR2" ' written to XMP sidecar.
Comment 5 xstej70 2012-08-31 18:39:03 UTC
Created attachment 73582 [details]
patchfile

I looked at the libkexiv2 sources and found something. I hope it doesn't introduce any regressions. Note that is is my second patch no anything and that it's my first day of sending patches...
After applying this patch the debug now says:

digikam(30533)/KEXIV2 KExiv2Iface::KExiv2::setIptcKeywords: /home/jarda-wien/temp/exiftool/gallery2.SRW  ==> Iptc Keywords:  veverka
digikam(30533)/KEXIV2 KExiv2Iface::KExiv2::save: KExiv2::metadataWritingMode 3
digikam(30533)/KEXIV2 KExiv2Iface::KExiv2::save: Will write Metadata to file "gallery2.SRW"
digikam(30533)/KEXIV2 KExiv2Iface::KExiv2::KExiv2Priv::saveToFile: "gallery2.SRW" is TIFF based RAW file supported but writing mode is disabled.  Metadata not saved.
digikam(30533)/KEXIV2 KExiv2Iface::KExiv2::save: Metadata for file "gallery2.SRW" written to file.
digikam(30533)/KEXIV2 KExiv2Iface::KExiv2::save: Will write XMP sidecar for file "gallery2.SRW"
digikam(30533)/KEXIV2 KExiv2Iface::KExiv2::save: Metadata for file ' "gallery2.SRW" ' written to XMP sidecar.
Comment 6 xstej70 2012-08-31 18:58:13 UTC
FYI this is the log after ticking the write to RAW (experimental) option:

digikam(30699)/KEXIV2 KExiv2Iface::KExiv2::setIptcKeywords: /home/jarda-wien/temp/exiftool/gallery1.SRW  ==> Iptc Keywords:  veverka
digikam(30699)/KEXIV2 KExiv2Iface::KExiv2::save: KExiv2::metadataWritingMode 3
digikam(30699)/KEXIV2 KExiv2Iface::KExiv2::save: Will write Metadata to file "gallery1.SRW"
digikam(30699)/KEXIV2 KExiv2Iface::KExiv2::KExiv2Priv::saveToFile: File Extension:  "srw"  is supported for writing mode
digikam(30699)/KEXIV2 KExiv2Iface::KExiv2::save: Metadata for file "gallery1.SRW" written to file.
Comment 7 caulier.gilles 2012-08-31 21:02:23 UTC
Štěpánek,

If you don't want to have SRW file touched through metadata, why you add this type of file in list of support RAW files in writing mode by Exiv2 library with your patch ?

Andreas,

SRW files are really supported in writing mode with last Exiv2 version ?

Gilles Caulier
Comment 8 xstej70 2012-09-01 07:04:01 UTC
Well, my original problem was that digikam was writing metadata in the first place with no way to disable it. It seemed that write support was there and working plus look here: http://www.exiv2.org/whatsnew.html#item4 and the registry in image.cpp says srw read/write support.

A quick grep search found that the srw file format is not mentioned anywhere in the sources while other formats are so I added it. Until now, it behaves as expected.
Comment 9 Marcel Wiesweg 2012-09-23 14:13:44 UTC
Gilles: Looking at KExiv2::KExiv2Priv::saveToFile, the list of supported RAW formats is a) static and b) at the status of exiv2 0.19.1. 0.21 added SRW, 0.23 CR2.

Andreas: Is there a way to query from libexiv2 the RAW formats supported for writing? Or should we continue to rely on versionNumber() and our knowledge of the files supported at that time?
Comment 10 Andreas Huggel 2012-09-23 15:06:18 UTC
Marcel, Gilles,

We have this registry
http://dev.exiv2.org/projects/exiv2/repository/entry/trunk/src/image.cpp#L105

And functions ImageFactory::checkMode() and Image::checkMode() to query it.

So for a given image of any type, if Exiv2 can open it (and determine its type in the process), the idea is that you should be able to use Image::checkMode() to determine the level of metadata support for the image.

Without an image, you need to know the Exiv2 "image type" of a particular format, to be able to query ImageFactory::checkMode(), which is not practical, as it still requires the app to know about Exiv2 internals.

Andreas
Comment 11 Marcel Wiesweg 2012-09-28 20:26:00 UTC
Thanks Andreas. Two more questions:
- changelog says CR2 is supported for writing, the registry you pointed to says it is read-only. Does it work?
- CRW does principally not support XMP?
Comment 12 Marcel Wiesweg 2012-09-29 12:32:44 UTC
Git commit 0364c48d64a4f492600f94f539324b24321a3df7 by Marcel Wiesweg.
Committed on 28/09/2012 at 22:40.
Pushed by mwiesweg into branch 'master'.

Rely on Exiv2 to definitely tell us that a file is not supported for writing, so that newly added support is not ignored, rather than
using a static list of file suffixes.

We keep a static list to apply the "do not write to raw" setting, as the image mimetype does not reliably identify a RAW image.
The "not supported" list is not used to fail, instead we check the possible write mode in saveOperations.

M  +47   -19   libkexiv2/kexiv2_p.cpp
M  +1    -1    libkexiv2/kexiv2_p.h

http://commits.kde.org/libkexiv2/0364c48d64a4f492600f94f539324b24321a3df7
Comment 13 Andreas Huggel 2012-10-02 06:40:30 UTC
(In reply to comment #11)
> Thanks Andreas. Two more questions:
> - changelog says CR2 is supported for writing, the registry you pointed to
> says it is read-only. Does it work?

That's a bug, the registry should include writing. It works, we have not received any negative feedback.

> - CRW does principally not support XMP?

Apparently it does. From the exiftool tag doc: "CRW images also support the addition of a CanonVRD trailer, which in turn supports XMP. This trailer is created automatically if necessary when ExifTool is used to write XMP to a CRW image."
Exiv2 does not support that.

Andreas
Comment 14 xstej70 2012-10-11 12:54:14 UTC
(In reply to comment #12)

I compiled libkexiv2 with the latest patch and the result is that it doesn't work as expected yet.
This is from digikam 2.9, 3.0 beta 2 and today's git (all the same):

digikam(3660)/KEXIV2 KExiv2Iface::KExiv2::save: KExiv2::metadataWritingMode 3
digikam(3660)/KEXIV2 KExiv2Iface::KExiv2::save: Will write Metadata to file "gallery1.SRW"
digikam(3660)/KEXIV2 KExiv2Iface::KExiv2::Private::saveToFile: "gallery1.SRW" is a TIFF based RAW file, writing to such a file is disabled by current settings.
digikam(3660)/KEXIV2 KExiv2Iface::KExiv2::save: Metadata for file "gallery1.SRW" written to file.

As you can see the log mentions RAW file writing being disabled, yet it gets written to...
With the patch that I proposed, everything worked as expected. I understand that there is a new a approach now and I don't see any errors in the current implementation but for some reason SRW files are handled R/W even if write to RAW is disabled in the options.
There is a workaround, the "write to XMP sidecar only" option.
Comment 15 Marcel Wiesweg 2012-10-11 18:33:03 UTC
Git commit ab6f65f2edd4463260dc3cbf4d86075f2f51ca0f by Marcel Wiesweg.
Committed on 11/10/2012 at 20:30.
Pushed by mwiesweg into branch 'master'.

Dont forget to fail if writing to RAW files is switched off

M  +1    -0    libkexiv2/kexiv2_p.cpp

http://commits.kde.org/libkexiv2/ab6f65f2edd4463260dc3cbf4d86075f2f51ca0f
Comment 16 xstej70 2012-10-15 15:21:05 UTC
Thanks, works like a charm!

(In reply to comment #15)
> Git commit ab6f65f2edd4463260dc3cbf4d86075f2f51ca0f by Marcel Wiesweg.
> Committed on 11/10/2012 at 20:30.
> Pushed by mwiesweg into branch 'master'.
> 
> Dont forget to fail if writing to RAW files is switched off
> 
> M  +1    -0    libkexiv2/kexiv2_p.cpp
> 
> http://commits.kde.org/libkexiv2/ab6f65f2edd4463260dc3cbf4d86075f2f51ca0f
Comment 17 caulier.gilles 2022-04-08 05:27:44 UTC
Git commit 232040bdd51ba615ba3c2ac04e4846a3cf80c1af by Gilles Caulier.
Committed on 08/04/2022 at 05:24.
Pushed by cgilles into branch 'master'.

More files closed with ExifTool backend used to write metadata to RAW files instead Exiv2.
Related: bug 193228, bug 235171, bug 236127, bug 291627, bug 317745, bug 234181, bug 366406, bug 168064, bug 134487
FIXED-IN: 8.0.0

M  +14   -4    NEWS

https://invent.kde.org/graphics/digikam/commit/232040bdd51ba615ba3c2ac04e4846a3cf80c1af