From e0fddee12829bca85565ca903a7d6e464c8cb2ec Mon Sep 17 00:00:00 2001 From: Roman Joost Date: Sun, 28 Jun 2009 15:26:24 +1000 Subject: [PATCH] Set scalar properties for XMP (exif). --- plug-ins/metadata/exif-decode.c | 50 ++++++++++++++++++++------------- plug-ins/metadata/metadata.c | 7 +++-- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/plug-ins/metadata/exif-decode.c b/plug-ins/metadata/exif-decode.c index 7e0968a948..96e3a09258 100644 --- a/plug-ins/metadata/exif-decode.c +++ b/plug-ins/metadata/exif-decode.c @@ -33,36 +33,44 @@ #include "exif-decode.h" -/* prototypes of local functions */ -// static void exif_iter_content (XMPModel *xmp_model, -// ExifData *data); + static void exif_foreach_content_cb (ExifContent *content, XMPModel *xmp_model); static void exif_foreach_entry_cb (ExifEntry *entry, XMPModel *xmp_model); - +/** + * xmp_merge_from_exifbuffer: + * @xmp_model: pointer to the #XMPModel in which the results will be stored + * @image_ID: id of the image where the exif data parasite is attached to + * @error: return location for a #GErrror + * + * Load the Exif data, which is attached to the image as a parasite. The + * parsed Exif data is merged into the XMP model. + * + * Return value: %TRUE on success, %FALSE if an error occured during + * reading/writing + * + **/ gboolean xmp_merge_from_exifbuffer (XMPModel *xmp_model, gint32 image_ID, GError **error) { ExifData *exif_data; - GimpParasite *parasite = gimp_image_parasite_find(image_ID, "exif-data"); + GimpParasite *parasite = gimp_image_parasite_find (image_ID, "exif-data"); - if (parasite) - { - g_warning ("Found parasite, extracting exif"); - exif_data = exif_data_new_from_data (gimp_parasite_data (parasite), - gimp_parasite_data_size (parasite)); - if (exif_data) { - exif_data_foreach_content (exif_data, - (void *) exif_foreach_content_cb, - xmp_model); - } else { - g_printerr ("\nSomething went wrong, when reading from buffer.\n"); - return FALSE; - } + if (!parasite) + return FALSE; + + exif_data = exif_data_new_from_data (gimp_parasite_data (parasite), + gimp_parasite_data_size (parasite)); + if (exif_data) { + exif_data_foreach_content (exif_data, + (void *) exif_foreach_content_cb, + xmp_model); + } else { + return FALSE; } return TRUE; @@ -79,6 +87,10 @@ static void exif_foreach_entry_cb (ExifEntry *entry, XMPModel *xmp_model) { - g_printerr ("\nWuff! Wuff!:"); + char value[1024]; + xmp_model_set_scalar_property (xmp_model, + XMP_SCHEMA_EXIF, + exif_tag_get_name (entry->tag), + exif_entry_get_value (entry, value, sizeof (value))); } diff --git a/plug-ins/metadata/metadata.c b/plug-ins/metadata/metadata.c index 78fc7d59cf..f34b54e95b 100644 --- a/plug-ins/metadata/metadata.c +++ b/plug-ins/metadata/metadata.c @@ -397,7 +397,7 @@ run (const gchar *name, - METADATA_MARKER_LEN, TRUE, &error)) { - g_printerr ("Metadata parasite seems to be corrupt"); + g_printerr ("\nMetadata parasite seems to be corrupt"); /* continue anyway, we will attach a clean parasite later */ } gimp_parasite_free (parasite); @@ -445,7 +445,10 @@ run (const gchar *name, if (! xmp_merge_from_exifbuffer (xmp_model, image_ID, &error)) - status = GIMP_PDB_EXECUTION_ERROR; + { + status = GIMP_PDB_EXECUTION_ERROR; + g_printerr ("\nExif to XMP merge failed.\n"); + } #endif } else if (! strcmp (name, GET_PROC))