Bug 159158

Summary: Tags moved in tree are duplicated in the IPTC metadata
Product: [Applications] digikam Reporter: Jean-Marc Liotier <jm>
Component: Metadata-IptcAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kdebugsystem, marcel.wiesweg, monoceros84
Priority: NOR    
Version: 0.9.2   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 1.0.0
Sentry Crash Report:

Description Jean-Marc Liotier 2008-03-11 21:38:13 UTC
Version:           0.9.2-final (using KDE 3.5.8)
Installed from:    Ubuntu Packages
OS:                Linux

Let's take a file an tag it with the word "Senegal", then synchronize the images from the database.

21:12 jim@senecio ~/digikam_albums/Senegal2008% exiv2 -p iptc img_1640.jpg
Iptc.Application2.Program                    String      7  digiKam
Iptc.Application2.ProgramVersion             String     11  0.9.2-final
Iptc.Application2.Keywords                   String      8  Senegal

Wait - surely I'm going to visit other countries, so let's make a "Place" category and put "Senegal" in it by drag and dropping it there in the "Tag Filters" tree display on the right of the main window. 

21:13 jim@senecio ~/digikam_albums/Senegal2008% exiv2 -p iptc img_1640.jpg
Iptc.Application2.Program                    String      7  digiKam
Iptc.Application2.ProgramVersion             String     11  0.9.2-final
Iptc.Application2.Keywords                   String      8  Senegal
Iptc.Application2.Keywords                   String     14  Place/Senegal

Ooops. "Place/Senegal" is correct, but "Senegal" has not been deleted.

Maybe this is consistent with Digikam's policy of not harming existing data inside the picture file. But from my point of view this is not what I expected.
Comment 1 Jean-Marc Liotier 2008-03-11 21:39:34 UTC
May be somehow related with bug 15873 (http://bugs.kde.org/show_bug.cgi?id=158713) and bug 136254 (http://bugs.kde.org/show_bug.cgi?id=136254).
Comment 2 Jean-Marc Liotier 2008-03-11 21:59:13 UTC
By the way, if you are hit by this bug, here is the workaround :
- 'exiv2 rm -d i yourfile.jpg' or 'exiv2 rm -d i *.jpg' will erase IPTC metadata.
- then hit "Synchronize images with the database" and your files shall soon be populated by the right tags fresh from the the database and with no trace of the moved or erased tags.
Comment 3 Andi Clemens 2008-04-29 10:58:38 UTC
I can confirm this bug. I have to remove the IPTC metadata first and synchronize the images with the database, otherwise old tags are still in the metadata or moved tags are duplicated.
Comment 4 x3ri7yz02 2008-05-27 04:39:48 UTC
Confirmed in SVN (revisions:  exiv2 1463, graphics 813168, libs 813167)
Comment 5 caulier.gilles 2008-05-27 12:14:07 UTC
Marcel,

I suspect a bug in MetadataHub. 

Same in http://bugs.kde.org/show_bug.cgi?id=152199

Gilles Caulier
Comment 6 Marcel Wiesweg 2008-06-06 23:53:57 UTC
This is due to digikam's behavior: Existing tags from Metadata are kept.

There are two possible solutions to this problem:
1) When the tag is changed, the metadata of all images with this tag would need to be resynchronized automatically, actually only those files where the tag has been written to the metadata.
2) Digikam would need to know that Places/Senegal was formerly Senegal. This boils down to keep a map of tag movement history.

You see that both solution have significant side effects.
Comment 7 x3ri7yz02 2008-06-07 09:15:20 UTC
Hi Marcel,

I think that (2) is unnecessarily complicated.  But the approach in (1) seems to be what a user would anticipate and expect:  moving a tag around inside the tag tree should update images which include that tag.

Is there a case where this behaviour would be incorrect?

PS.  Could a general function to update relevant images after changes to the tag tree also help solve bugs like #152199?
Comment 8 caulier.gilles 2008-06-12 18:34:14 UTC
To Marcel #6,

I vote for 1). It's more simple.

To x3ri7yz02 #7,

Try Tools/Update Metadata Database menu entry

Gilles Caulier
Comment 9 Geoff King 2008-06-13 14:39:15 UTC
Considering #2 - What about iptc fields that Digikam doesn't use? They could become unnecessarily deleted if you remove all iptc.  In my case last year I had some old tags in "supplemental categories" and some other iptc fields that would not have been repopulated using this method.  This might be useful:
exiv2 -v -M"del Iptc.Application2.Keywords" [filename]

Also for anyone interested Arnd and I both wrote scripts to scan directories and remove tags using this method last December.  They should be available on the mailing list. One example: http://mail.kde.org/pipermail/digikam-users/2007-December/004507.html

Comment 10 Mathias Lindner 2008-09-22 16:47:17 UTC
Don't forget the action of renaming a tag. Should behave the same way than moving a tag in the tree.
Comment 11 caulier.gilles 2009-06-16 10:44:04 UTC
SVN commit 982571 by cgilles:

This is a long standing bug about Tag synchronization to XMP and IPTC keywords.
To wrap around this problem, we remove all previous keywords before to apply new sets.
Marcel, i think MetadataHub is right : new and old tags lists are fine. Problem must be in libkexiv2.
Anyway this patch fix the problem for the moment.
BUGS: 175321
BUGS: 159158
BUGS: 141912
BUGS: 186308
CCMAIL: marcel.wiesweg@gmx.de


 M  +7 -4      metadatahub.cpp  


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