Set scalar properties for XMP (exif).
This commit is contained in:
parent
7230d2673c
commit
e0fddee128
2 changed files with 36 additions and 21 deletions
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue