Bug 209382

Summary: Caption not being updated in image file
Product: [Applications] digikam Reporter: Stefan Hühne <xeno>
Component: Metadata-DateAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: ahuggel, caulier.gilles, marcel.wiesweg
Priority: NOR    
Version: 1.0.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 1.5.0
Sentry Crash Report:
Attachments: Proposed patch to correct UI behavior

Description Stefan Hühne 2009-10-04 12:12:15 UTC
Version:           1.0.0 beta4 (using KDE 4.3.1)
OS:                Linux
Installed from:    SuSE RPMs

When setting the caption via the right side-bar "Caption/Tags - Description-Caption" the caption is not updated in the image file. Even "Image - Write Metadata to Image" does not work.
On the other hand, "Image - Edit Metadat - Edit..." works great.
As far as I've observed so far, only the caption is affected.

Component information:
digiKam version 1.0.0-beta4
Exiv2 can write to Jp2: No
Exiv2 can write to Jpeg: Yes
Exiv2 can write to Pgf: No
Exiv2 can write to Png: No
Exiv2 can write to Tiff: No
Exiv2 supports XMP metadata: Yes
LibCImg: 130
LibExiv2: 0.17.1
LibJPEG: 62
LibJasper: 1.900.1
LibKDE: 4.3.1 (KDE 4.3.1) "release 168"
LibKExiv2: 0.6.0
LibKdcraw: 0.5.0
LibLCMS: 118
LibPGF: 6.09.24
LibPNG: 1.2.39
LibQt: 4.5.2
LibRaw: 0.7.2
LibTIFF: LIBTIFF, Version 3.8.2 Copyright (c) 1988-1996 Sam Leffler Copyright (c) 1991-1996 Silicon Graphics, Inc.
Marble widget: 0.8.1
Parallelized demosaicing: Yes
LibGphoto2: 2.4.3
LibKipi: 0.4.0
Comment 1 caulier.gilles 2009-10-04 12:36:55 UTC
I think it's fixed with current implementation from svn (1.0.0-beta5)

Gilles Caulier
Comment 2 Stefan Hühne 2009-10-06 21:46:03 UTC
Hi Gilles,
I'm afraid it has not been fixed. I've just compiled beta5 and the bug is still there, although slightly changed:

Edits in the caption via the right sidebar are still not written to file. 
But at least, captions in different languages are displayed now. In beta4 everthing but x-default vanished from the list after having entered text.

Editing via image-metadata still works. Although the different language captions entered via sidebar don't seem to show up in the edit-xmp dialog. Only the last entered caption from the sidebar seems to show up under edit-caption.

digiKam version 1.0.0-beta5
Exiv2 kann in JP2 speichern: Keine
Exiv2 kann in JPEG speichern: Ja
Exiv2 kann in PNG speichern: Keine
Exiv2 kann in Pgf speichern: Keine
Exiv2 kann in TIFF speichern: Keine
Exiv2 unterstützt XMP-Metadaten: Ja
LibCImg: 130
LibExiv2: 0.17.1  <--- hope this is no problem, since I didn't succeed in linking with 0.18
LibJPEG: 62
LibJasper: 1.900.1
LibKDE: 4.3.1 (KDE 4.3.1) "release 169"
LibKExiv2: 0.6.0
LibKdcraw: 0.5.0
LibLCMS: 117
LibPGF: 6.09.33
LibPNG: 1.2.31
LibQt: 4.5.2
LibRaw: 0.7.2
LibTIFF: LIBTIFF, Version 3.8.2 Copyright (c) 1988-1996 Sam Leffler Copyright (c) 1991-1996 Silicon Graphics, Inc.
Marble-Widget: 0.8.1
Parallelized demosaicing: Ja
LibGphoto2: 2.4.3
LibKipi: 0.4.0

Any idea? Or any further experiments you would like me to do?

Stefan
Comment 3 Stefan Hühne 2009-10-07 08:21:16 UTC
I've made some more experiments. And it is really confusing.
Whatever I tried, a caption entered on the sidebar NEVER made it into the jpg. Although, sometimes it is displayed as thaumbnail caption and sometimes even shows in the metadata-caption dialog. 

Editing metadata-xmp caption seems not to properly synchronize with the sidebar caption. x-default was synchronized, an additional de-DE caption was not. Obviously, two different de-DE captions are stored. And while the DE xmp-caption is written to jpg the DE sidebar caption tends to be used as thumbnail caption (maybe because I use digikam with german language) - as I said: confusing.

But maybe it's a matter of my false (naive) expectations. Is there a documentation about
- how the many different metadata-input options of digikam are internally synchronized
- how and with which precedence the digikam-metadata are used for display
- how the digikam-metadata items are synchronized with XFIF/EXIF/IPTC/XMP-metadata in image files

I would even try understanding the source code if I had some hints where to begin...

Stefan
Comment 4 caulier.gilles 2009-10-07 08:51:36 UTC
>LibKExiv2: 0.6.0

I recommend to use code from svn, where a lots of problem have been fixed. Code is there :

http://websvn.kde.org/trunk/KDE/kdegraphics/libs/libkexiv2/

>LibExiv2: 0.17.1

Exiv2 0.18.2 will be better there... 

Few pointers in code :


* In this code, you can see the main loop which update meatadata from items when you press Apply button from right sidebar :
http://lxr.kde.org/source/extragear/graphics/digikam/libs/imageproperties/imagedescedittab.cpp#536

* This class is a hub to change metadata from DB and image files :

http://lxr.kde.org/source/extragear/graphics/digikam/digikam/metadatahub.cpp#516

* This class do all main jobs relevant of image metadata :

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp#257

* previous class is a derivate one from this wrapper around Exiv2 library :

http://lxr.kde.org/source/KDE/kdegraphics/libs/libkexiv2/libkexiv2/kexiv2.h

Of course all sub level action in image metadata are done by Exiv2, but now you have the scheme of code.

Gilles
Comment 5 caulier.gilles 2009-10-07 09:01:26 UTC
Few notes :

- In icon view, x-default comment is always displayed, not other.

- Due to XMP spec, an image must have x-default comment first before to have a dedicated language comment, as german for example.

- testing there : x-default comment is displatched to metadata at the right place :

* Exif
* IPTC
* XMP

- All other language comments are only written at XMP.
Comment 6 caulier.gilles 2009-10-07 09:18:08 UTC
Marcel,

I can see dysfunctions in caption gui tool from right sidebar. This can be relevant of your last patch before beta5 release...

1/ take a picture without comment. Select x-default (normally it's selected automatically). Enter text and press "+" green button to add text to the list. Text disappear and x-default is not checked to show that x-default comment is assigned. But comment map is right in memory. If you press Apply button, comment will be written to image. Note that if you enter comment + author name, only comment disappear, not Author name...

2/ take a picture without comment. Enter x-default comment+enter, see the previous dysfunction from 1/. Now select "fr-FR" to enter French description. Normally this entry is empty because there is no other language alternative comment in image. Look like Caption is cleared (ok), but not Author name.

3/ Take another picture without comment. Set x-default comment with author name, and another language comment + author name. See the dyfunctions fro 1/ and 2/. But no problem, map in memory is ready to be written to image. So let's go : press Apply button. Now look the result in Exif, IPTC, and XMP :

// ---------------------------------------------------------------------------

File name: 05.jpg (Standard EXIF Tags)

>>> Interoperability <<<

Interoperability Version : 1.00
Interoperability Index : R98


>>> Embedded Thumbnail <<<

JPEG Interchange Format Length : 2434
JPEG Interchange Format : 50662
Compression : JPEG (old-style)


>>> Image Information <<<

Y-Resolution : 72
YCbCr Coefficients : 299/1000 587/1000 114/1000
X-Resolution : 72
White Point : 313/1000 329/1000
Software : DYNAX 5D v1.00
Resolution Unit : inch
Processing Software : digiKam-1.0.0-beta6 (rev.: 1028753)
Print Image Matching : 80 114 105 110 116 73 77 0 48 51 48 48 0 0 0 6 0 1 0 22 0 22 0 2 1 0 0 0 0 3 0 0 0 52 1 0 5 0 0 0 1 1 0 0 0 0 1 16 128 0 0 0 0 0 23 209 0 0 39 16 0 0 8 5 0 0 39 16 0 0 5 212 0 0 39 16 0 0 12 39 0 0 39 16 0 0 24 113 0 0 39 16 0 0 2 120 0 0 39 16 0 0 0 195 0 0 39 16 0 0 2 97 0 0 39 16 0 0 29 22 0 0 39 16
Primary Chromaticities : 64/100 33/100 21/100 71/100 15/100 6/100
Orientation : top, left
Model : DYNAX 5D
Manufacturer : KONICA MINOLTA
Image Width : 2508
Image Length : 3766
Image Description : KONICA MINOLTA DIGITAL CAMERA
Exif IFD Pointer : 616
Document Name : 05.png
Date and Time : 2009:09:19 13:46:39
Compression : Uncompressed


>>> Photograph Information <<<

White Balance : Auto
User Comment : my default comment
Subject Area : 1504 1000 256 304
Sharpness : Normal
Scene Capture Type : Standard
Saturation : Normal
Pixel Y Dimension : 3766
Pixel X Dimension : 2508
Metering Mode : Multi-segment
Max Aperture Value : F3.5
Maker Note : 23 0 0 0 7 0 4 0 0 0 77 76 84 48 16 0 7 0 20 9 0 0 128 5 0 0 24 0 7 0 8 32 0 0 148 14 0 0 32 0 7 0 20 21 0 0 156 46 0 0 64 0 4 0 1 0 0 0 0 0 0 0 136 0 4 0 1 0 0 0 120 69 0 0 137 0 4 0 1 0 0 0 252 127 0 0 0 1 4 0 1 0 0 0 0 0 0 0 1 1 4 0 1 0 0 0 4 0 0 0 2 1 4 0 1 0 0 0 0 0 0 0 4 1 10 0 1 0 0 0 176 67 0 0 5 1 4 0 1 0 0 0 0 0 0 0 6 1 4 0 1 0 0 0 0 0 0 0 9 1 4 0 1 0 0 0 0 0 0 0 10 1 4 0 1 0 0 0 0 0 0 0 11 1 4 0 1 0 0 0 0 0 0 0 12 1 4 0 1 0 0 0 6 0 0 0 13 1 4 0 1 0 0 0 0 0 0 0 17 1 9 0 1 0 0 0 0 0 0 0 18 1 4 0 1 ...
Light Source : Unknown
Interoperability IFD Pointer : 50590
ISO Speed Ratings : 100
Gain Control : None
Focal Length In 35mm Film : 36.0 mm
Focal Length : 24.0 mm
FlashPix Version : 1.00
Flash : No, compulsory
FNumber : F9
Exposure Time : 1/125 s
Exposure Program : Auto
Exposure Mode : Auto
Exposure Bias : 0 EV
Exif Version : 2.21
Digital Zoom Ratio : 0.0
Date and Time (original) : 2009:09:19 13:46:39
Date and Time (digitized) : 2009:09:19 13:46:39
Custom Rendered : Normal process
Contrast : Normal
Components Configuration : YCbCr
Color Space : Uncalibrated
Brightness : 8.5

// ---------------------------------------------------------------------------

File name: 05.jpg (IPTC Records)

>>> IIM Application 2 <<<

Caption : my default comment
Date Created : 2009-09-19
Program : digiKam
Program Version : 1.0.0-beta6 (rev.: 1028753)
Time Created : 13:46:39+00:00

// ---------------------------------------------------------------------------

 File name: 05.jpg (XMP Schema)

>>> Dublin Core <<<

Description : my default comment, lang="fr-FR" Mon commentaire en Français


>>> digiKam schema <<<

Captions Author Names : cgilles-default, lang="fr-FR" cgilles-FR
Captions Date Time Stamps : 2009-10-07T09:04:46, lang="fr-FR" 2009-10-07T09:09:24


>>> Exif-specific Properties <<<

Date and Time Original : 2009:09:19 13:46:39
Pixel X Dimension : 2508
Pixel Y Dimension : 3766
User Comment : my default comment


>>> Adobe Photoshop <<<

Date Created : 2009-09-19T13:46:39


>>> TIFF Properties <<<

Date and Time : 2009-09-19T13:46:39
Image Description : my default comment
Image Length : 3766
Image Width : 2508
Orientation : top, left
Software : digiKam-1.0.0-beta6 (rev.: 1028753)


>>> Basic Schema <<<

Create Date : 2009-09-19T13:46:39
Creator Tool : digiKam-1.0.0-beta5 (rev. : 994760)
Metadata Date : 2009-09-19T13:46:39
Modify Date : 2009-09-19T13:46:39

Conclusion : For me, with current code from svn (libkexiv2 + digiKam), all writing in file metadata work fine, including mutiple selection of items at the same time from icon view. But Gui is completely broken and not suitable...

Gilles
Comment 7 Andreas Huggel 2009-10-07 09:23:38 UTC
> - Due to XMP spec, an image must have x-default comment first before to have a
> dedicated language comment, as german for example.

Just curious, what does digiKam show if there is _no_ x-default entry, only one in a specific language?

Exiv2 allows to write only a language-specific entry into a language alternative property.

Andreas
Comment 8 caulier.gilles 2009-10-07 09:27:50 UTC
Andreas,

It will show the specific alternative language present in file in comment editor, but in icon view nothing, because x-default comment do not exit.

From XMP stuff, i'm not too wrong if i said that x-default must exist in first and after all others alternative language comments ? XMP schema is not broken if no x-default exist but one (or more) alt languages entry is set ?

Gilles
Comment 9 caulier.gilles 2009-10-07 09:38:07 UTC
Andi,

Can you confirm #6 ?

Gilles
Comment 10 Andreas Huggel 2009-10-07 10:12:58 UTC
> XMP schema is not broken if no x-default exist but one (or more) alt languages entry is set ?

Yes, the x-default must come first in the array. And I think no x-default is valid. See also http://forums.adobe.com/thread/290946 especially the PS at the end.

Andreas
Comment 11 Andi Clemens 2009-10-07 11:00:32 UTC
(In reply to comment #9)
> Andi,
> 
> Can you confirm #6 ?
> 
> Gilles

For me images without a caption always have "x-default" assigned (they have a checker mark left to the language name).
I selected a bunch of images, removed the none-existing x-default caption so that it is not checked and tested point 1 from comment 6. I can confirm this.
I will test the rest later.
"Git bisect" should show the commit that caused this, if it really worked before.
Comment 12 Andi Clemens 2009-10-07 11:48:45 UTC
commit #1022407 seems to be responsible for point 1 in comment 6, I have not tested the rest yet.
Comment 13 caulier.gilles 2009-10-07 11:54:36 UTC
http://websvn.kde.org/?revision=1022407&view=revision

Gilles
Comment 14 Andi Clemens 2009-10-07 19:53:05 UTC
The second issue from comment 6 was introduced by this commit:
http://websvn.kde.org/?revision=1004617&view=revision
Comment 15 Marcel Wiesweg 2009-10-07 21:00:10 UTC
When fixing the UI I would suggest this behavior:
No add/update button. If you select a language without comment so far and type, a comment is added for that language. No need to press Add.
If you select a language with comment, the comment is shown. When you type, it is changed. No need to press Update.
If the user clears the comment text, the comment for the current language is removed. Same when clicking the Remove button.

In the future, we should store favorite languages in the config and group them at the top. That's not related here though.
Comment 16 Stefan Hühne 2009-10-08 21:17:04 UTC
With digikam und libkexiv2 from svn the original bug seems to be fixed. Editing the caption in the sidebar - even multilingual - is written to the image file :-)

But changes to the caption via image-metadata-caption or image-metadata-xml are only written to the file and are not reflected in the sidebar (although the language gets a checkmark). You have to "read metadata from image" to synchronize again. Is this a bug or a feature?

Stefan
Comment 17 Andi Clemens 2009-10-09 12:13:44 UTC
Adding another issue to comment #6:

Add a caption, press '+'.
Now try to select another language from the combobox, it is not possible. It will jump back to x-default all the time. You need to press "Apply" to make it work again.
Comment 18 Marcel Wiesweg 2009-10-10 16:24:16 UTC
Created attachment 37494 [details]
Proposed patch to correct UI behavior

Attaching a patch implementing the behavior as outlined above:
There is no Add or Update button any more, changes are directly accepted (as it was done before the language list was added). For removing the entry for a language, either the text can be cleared, or the clear button pressed.

For me this works well, but there are a lot of corner cases to be tested and we are close to release.
Given that the UI is completely broken in the current state however, I would commit this patch if noone complains here.
Comment 19 Andi Clemens 2009-10-10 16:43:50 UTC
I like this new way, the workflow is much more fluid now.
And at least the mentioned issues are not reproducible with the patch. So for me it is fine...

+1
Comment 20 caulier.gilles 2009-10-10 18:07:08 UTC
Marcel,

I'm agree. Workflow sound better now in Caption Edit tab...

But, altlangstredit object is also used in Template editor. How do you deal to remove add strings without buttons ? Is Caption Edit workflow is adapted to Template editor ? If yes, all is fine for me...

Another stuff, is about shared component to libkexiv2. Yes code is currently duplicated to this library. Why ? because i would to use common implementation into libkexiv2 shared between digiKam core and kipi-plugins (especially MetadataEdit plugin). altlangstredit is used in both.

This is want mean that you patch need to be applied to libkexiv2 from trunk (KDE 4.4)

Gilles
Comment 21 Marcel Wiesweg 2009-10-10 20:52:10 UTC
Just quickly tested template editor, seems to work fine. There is still a button to delete an entry. Alternatively, the text can be cleared, to the same effect.

I will update the libkexiv2 class as well. There is another class AltLangStringsEdit in the metadata edit plugin with similar API but considerably different implementation.
Comment 22 Marcel Wiesweg 2009-10-10 20:54:29 UTC
SVN commit 1033676 by mwiesweg:

Remove the Add/Update button in AltLangStrEdit, accept changes as soon as they are done.

CCBUG: 209382

 M  +70 -92    altlangstredit.cpp  
 M  +19 -13    altlangstredit.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1033676
Comment 23 Marcel Wiesweg 2009-10-10 20:54:40 UTC
SVN commit 1033677 by mwiesweg:

Update signal connections, add logic for some corner cases, use QMap::value() instead
QMap::operator[] everywhere - the latter adds a value if it does not exist.

CCBUG: 209382

 M  +46 -17    captionedit.cpp  
 M  +1 -1      captionedit.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1033677
Comment 24 Andi Clemens 2009-10-10 22:32:08 UTC
When pressing the "clear" button now, the caption field is not cleared anymore. Can you confirm this...?
Comment 25 Marcel Wiesweg 2009-10-17 13:14:40 UTC
SVN commit 1036526 by mwiesweg:

Make sure to clear caption field when delete button is pressed.

CCBUG: 209382

 M  +1 -1      altlangstredit.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1036526
Comment 26 Marcel Wiesweg 2009-12-19 16:08:06 UTC
Ok to close?
Comment 27 Andi Clemens 2010-10-01 23:22:07 UTC
SVN commit 1181722 by aclemens:

update

BUG: 209382

 M  +2 -1      NEWS  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1181722