libgimpbase: fix incorrect reading of iptc tags that appear more than once.

This is one of the problems mentioned in issue #5863. This commit only fixes
our loading (and saving) of this metadata.
Certain iptc tags like "Keywords" can appear multiple times. We were using
gexiv2_metadata_get_tag_string to get the value but that always returns
the first value so we replaced that by gexiv2_metadata_get_tag_multiple.
This commit is contained in:
Jacob Boerema 2020-11-16 13:01:55 -05:00 committed by Jehan
parent 501675b8a3
commit d0f67faf29
1 changed files with 28 additions and 7 deletions

View File

@ -838,14 +838,35 @@ gimp_metadata_serialize (GimpMetadata *metadata)
if (iptc_data)
{
for (i = 0; iptc_data[i] != NULL; i++)
{
value = gexiv2_metadata_get_tag_string (GEXIV2_METADATA (metadata),
iptc_data[i]);
escaped = gimp_metadata_escape (iptc_data[i], value, &base64);
g_free (value);
gchar **iptc_tags = iptc_data;
gchar *last_tag = NULL;
gimp_metadata_append_tag (string, iptc_data[i], escaped, base64);
while (*iptc_tags)
{
gchar **values;
if (last_tag && ! strcmp (*iptc_tags, last_tag))
{
iptc_tags++;
continue;
}
last_tag = *iptc_tags;
values = gexiv2_metadata_get_tag_multiple (GEXIV2_METADATA (metadata),
*iptc_tags);
if (values)
{
for (i = 0; values[i] != NULL; i++)
{
escaped = gimp_metadata_escape (*iptc_tags, values[i], &base64);
gimp_metadata_append_tag (string, *iptc_tags, escaped, base64);
}
g_strfreev (values);
}
iptc_tags++;
}
g_strfreev (iptc_data);