Bug 231114 - TEMPLATE : Empty (unset) fields of template overwrite existing used fields when applying template
Summary: TEMPLATE : Empty (unset) fields of template overwrite existing used fields wh...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Template (show other bugs)
Version: 7.3.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-17 16:15 UTC by Gus Gustafson
Modified: 2022-12-06 18:13 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gus Gustafson 2010-03-17 16:15:43 UTC
Version:           1.0.0 (using KDE 4.3.2)
OS:                Linux
Installed from:    Ubuntu Packages

Not sure if this is a bug or change request.

I use the metadata template to automatically fill a couple fields. However, I do not use the template for setting the location fields, such as sublocation, city, etc. In other words, those ones are left blank in the template.

However, I recently found that, after applying the template to a folder of images, this caused all the data in those location fields to be deleted.

I think that if there is already data in a field, when you apply a template, that data should not be touched unless the template has something different for that field.  It is better to leave more information, which can always be deleted later, than to delete information unexpectedly (at least, I did not expect to happen.) Or, perhaps the best way is to allow user to choose, for each field in template with null value, whether existing data will be removed. So, maybe each field has a checkbox (that appears or becomes active when null value is present) that you can check to "clear existing data?" or something.

Or, you can forget the checkbox and just let people clear fields on multiple files once the sidebar metadata-edit feature (for fields other than comment) is added, if that is something they need to do.

But I think it is bad to leave it deleting data.

Thanks for a great software.
Comment 1 Marcel Wiesweg 2010-03-17 19:03:56 UTC
I think there is a very similar bug report already, but I dont find it right now.
Comment 2 Gus Gustafson 2010-03-17 19:19:19 UTC
i wonder if you are referring to #203732:
https://bugs.kde.org/show_bug.cgi?id=203732
however, if so, that issue concerned inadvertent copying of the caption
field's data of the first file to the caption field of other files when
applying templates. it seemed to me the issue I describe is different, since
caption is not even a field that can be set by the template.


On Wed, Mar 17, 2010 at 1:03 PM, Marcel Wiesweg <marcel.wiesweg@gmx.de>wrote:

> https://bugs.kde.org/show_bug.cgi?id=231114
>
>
>
>
>
> --- Comment #1 from Marcel Wiesweg <marcel wiesweg gmx de>  2010-03-17
> 19:03:56 ---
> I think there is a very similar bug report already, but I dont find it
> right
> now.
>
> --
> Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
>
Comment 3 Marcel Wiesweg 2010-03-17 21:43:50 UTC
No you're right that's not this bug. At least I'm sure to have talked about checkboxes or similar solutions a longer time ago.
Comment 4 Milan Knížek 2010-04-14 20:16:32 UTC
The topic is being discussed also here
https://bugs.kde.org/show_bug.cgi?id=144858
Comment 5 caulier.gilles 2012-01-29 22:11:53 UTC
*** Bug 292801 has been marked as a duplicate of this bug. ***
Comment 6 Gus Gustafson 2013-03-17 22:48:08 UTC
This is a critical bug. Using the template feature of digiKam causes unexpected data loss. Templates actively delete metadata in fields that are not set in the template. 

I cannot use template, as they have deleted the City, Country, and Sublocation data on many, many photos. This has thrown hours of work in the trash.

This is very bad behavior.

Users: You have been warned.
Comment 7 Gus Gustafson 2014-08-28 18:23:01 UTC
Hello Giles,
Hope you're doing well.
I see that you changed the first word in the title of this bug from "Unused" to "Used", but I believe this is not correct. As I understand it, it is correct originally. It is fields that are NOT used in the template that are actively overwriting existing data in those fields...
This is why I no longer use templates in DigiKam, instead using exiv2 directly for the desired fields...
Comment 8 Milan Knížek 2014-08-29 11:42:32 UTC
(In reply to Gus Gustafson from comment #7)
> I see that you changed the first word in the title of this bug from "Unused"
> to "Used", but I believe this is not correct. As I understand it, it is
Well spotted.

I just tested again with digiKam 4.2.0 and indeed the application of the template overwrites silently any data that existed, no matter that the corresponding field in the template is empty.

Not only does it overwrite existing field text with an an empty one, it also sets the various keys in XMP, even that there are empty and there is no reason for such a key to be written to XMP.

As you wrote, it is dangerous to use the templates atm and probably not many people use them anyway - at least based on the short "CC List" of this bug.

Perhaps the bug title should be changed to "Empty (unset) template fields erase already populated fields of the image metadata once the template is applied"?
Comment 9 Justin Zobel 2021-03-09 05:51:32 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 10 Milan Knížek 2021-04-09 18:33:17 UTC
In the current version of digiKam, the bug still exhibits as described.
Comment 11 jm7@acm.org 2021-07-21 14:28:40 UTC
Its still in 

Build date: 7/18/2021 7:09 PM (target: RelWithDebInfo)
Rev.: 63b3a6b6850e9a526f9aaa0955b3a24a534f537c
Comment 12 jm7@acm.org 2022-08-02 02:15:36 UTC
I've just verified it's still in the most recent weekly:

Build date: 7/29/2022 7:40 AM (target: RelWithDebInfo)
Revision: 19a12d8a1716782631c1544138d6ba67dcb1913e
Branch: qt5-maintenance
Comment 13 jm7@acm.org 2022-08-02 02:20:17 UTC
I've just verified it's still in the most recent weekly:

Build date: 7/29/2022 7:40 AM (target: RelWithDebInfo)
Revision: 19a12d8a1716782631c1544138d6ba67dcb1913e
Branch: qt5-maintenance

I also noticed that there does not seem to be a way to make the country be blank in the template.  I believe this also needs to be fixed at the same time so that it is possible to not set the country.

I need to find a way around this as it is preventing me from working at updating my contact information.  (400k images and increasing.  5k locations and increasing).
Comment 14 Maik Qualmann 2022-08-03 09:21:49 UTC
Hi Gilles,

I would implement it so that we have an option in the template whether it should replace or merge metadata.
Individually for each saved template. Do you think it's the right way?

Maik
Comment 15 caulier.gilles 2022-08-03 11:30:20 UTC
Hi Maik,

Yes, i can be.

I recommend also to look also how Clementine merge metadata when editing audio track properties.

https://clementine-player.github.io/pages/images//screenshots/clementine-0.7-3.png

If you select more than one tracks to edit properties, a change somewhere will be applied to all tracks as well with a smart merge operation if field already exists in metadata. Just try, it's simple to use and will give us an idea how it work.

Gilles
Comment 16 Maik Qualmann 2022-12-06 18:12:46 UTC
Git commit d672e63c7174e09935b27bcdd55e3d5fb1627791 by Maik Qualmann.
Committed on 06/12/2022 at 18:11.
Pushed by mqualmann into branch 'master'.

change template behavior to merge the metadata
- empty template fields no longer overwrite metadata
- fix removing template when using sidebar
- no empty metadata is written.
Related: bug 449754

M  +2    -2    NEWS
M  +4    -7    core/dplugins/bqm/metadata/assigntemplate/assigntemplate.cpp
M  +2    -14   core/libs/fileactionmanager/metadatahub.cpp
M  +71   -0    core/libs/metadataengine/containers/metadatainfo.cpp
M  +2    -0    core/libs/metadataengine/containers/metadatainfo.h
M  +48   -0    core/libs/metadataengine/containers/template.cpp
M  +5    -0    core/libs/metadataengine/containers/template.h
M  +90   -36   core/libs/metadataengine/dmetadata/dmetadata_iptc.cpp
M  +102  -57   core/libs/metadataengine/dmetadata/dmetadata_template.cpp
M  +3    -8    core/libs/properties/captions/disjointmetadata.cpp
M  +19   -2    core/libs/properties/captions/itemdescedittab_infoview.cpp
M  +8    -8    core/utilities/import/backend/cameracontroller.cpp

https://invent.kde.org/graphics/digikam/commit/d672e63c7174e09935b27bcdd55e3d5fb1627791