Problem getting/setting repeatable/non-repeatable Iptc tags
Description
The Iptc specification allows for both repeatable (multiple value) and non-repeatable (single value) tags (for supported tags see Exiv2, Iptc - column R). gexiv2 does not handle the getting/setting correctly in all circumstances.
Applies to
Tested on gexiv2 0.12.1.x, although many previous versions are likely to be also affected.
Reproduction
Getting:
For a repeatable tag containing more than one value. When using
gexiv2_metadata_[try_]get_tag_string()
, gexiv2_metadata_[try_]get_tag_raw()
or gexiv2_metadata_[try_]get_tag_interpreted_string()
only the first value of the repeatable tag is returned.
e.g. Iptc.Application2.Keywords
containing "Keyword 1"
, "Keyword 2"
and "Keyword 3"
gchar* single_value = gexiv2_metadata_get_tag_string(metadata, "Iptc.Application2.Keywords");
// single_value contains "Keyword 1" but expected "Keyword 1, Keyword 2, Keyword 3"
Setting:
For a non-repeatable tag. When using gexiv2_metadata_[try_]set_tag_multiple()
, the last value of the array is not always set.
e.g. If Iptc.Application2.EditStatus
is not set
gchar* values = g_new(gchar*, 3);
values[0] = g_strdup("New Edit Status 1");
values[1] = g_strdup("New Edit Status 2");
values[2] = NULL;
gboolean result = gexiv2_metadata_set_tag_string(metadata, "Iptc.Application2.EditStatus", values);
// - "Iptc.Envelope.ProductId" contains "New Edit Status 1" but expected "New Edit Status 2"
// - result == TRUE
e.g. If Iptc.Application2.EditStatus
contains a value - "Old Edit Status"
gchar* values = g_new(gchar*, 3);
values[0] = g_strdup("New Edit Status 1");
values[1] = g_strdup("New Edit Status 2");
values[2] = NULL;
gboolean result = gexiv2_metadata_set_tag_string(metadata, "Iptc.Application2.EditStatus", values);
// - "Iptc.Envelope.ProductId" contains "Old Edit Status" but expected "New Edit Status 2"
// - result == TRUE
For a repeatable tag. When using gexiv2_metadata_[try_]set_tag_string()
, the value is not added to the tag (as with Xmp - e.g. xmpBag type) but replaces the first value stored.
e.g. If Iptc.Application2.Keywords
contains values "Red"
, "Green"
and "Blue"
gboolean result = gexiv2_metadata_set_tag_string(metadata, "Iptc.Application2.Keywords", "White");
// - "Iptc.Application2.Keywords" contains "White", "Green" and "Blue".
// Expected "Red", "Green", "Blue" and "white".
// - result == TRUE
Additional Information
As exiv2 provides the metadata processing, the issues with setting have been raised upstream (#1395).