libgimpbase: fix #10557 missing XMP namespace "Item"

With the sample image that contains the XMP namespace Item with the
correct url included, it is not returning the url when we ask for it.
This seems to be an exiv2 issue, but needs more research.

What GIMP doesn't do, is report that the namespace url we were looking
for wasn't found, and make sure that this doesn't block us from
handling all XMP tags.

To improve this on our end, we check if there was an error getting the
url, and if yes:
- We generate a warning message
- We create a dummy namespace url, with a special check for the missing
Item namespace to give it the correct known namespace url.
This commit is contained in:
Jacob Boerema 2024-01-04 15:24:30 -05:00
parent c4cf0af1da
commit aeb1c726b9
1 changed files with 30 additions and 2 deletions

View File

@ -915,9 +915,37 @@ gimp_metadata_add_namespace (GHashTable *namespaces,
{ {
if (! g_hash_table_lookup (namespaces, prefix)) if (! g_hash_table_lookup (namespaces, prefix))
{ {
gchar *namespace_url; gchar *namespace_url;
GError *error = NULL;
namespace_url = gexiv2_metadata_try_get_xmp_namespace_for_tag (prefix, NULL); namespace_url = gexiv2_metadata_try_get_xmp_namespace_for_tag (prefix, &error);
if (! namespace_url)
{
/* Weird, we didn't find the namespace url.
Let's add a dummy url, that way we can keep the tags. */
if (error)
{
g_warning ("XMP namespace url not found! %s", error->message);
g_clear_error (&error);
}
/* Fix the one namespace url we know of, and add a generic fix for
any others. */
if (g_strcmp0 (prefix, "Item") == 0)
/* FIXME Remove this specific check for Item after this is fixed
in our dependencies (exiv2?), see issue #10557. */
namespace_url = g_strdup ("http://ns.google.com/photos/1.0/container/item/");
else
namespace_url = g_strdup_printf ("http://missing-url.org/%s/", prefix);
if (! gexiv2_metadata_try_register_xmp_namespace (namespace_url,
prefix, &error))
{
g_warning ("Registering XMP namespace failed! %s\n", error->message);
g_clear_error (&error);
}
}
if (namespace_url) if (namespace_url)
{ {