mirror of https://github.com/GNOME/gimp.git
Merges the exif-data to the xmp-model.
Added a function to merge the Exif data into the xmp model. The function is using the image id and to access the Exif data parasite. For each Exif property a corresponding value in the XMP model is created.
This commit is contained in:
parent
b2c20bdbda
commit
7230d2673c
|
@ -50,6 +50,8 @@
|
|||
void gimp_metadata_store_exif (gint32 image_ID,
|
||||
ExifData *exif_data)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
GimpParasite *parasite = NULL;
|
||||
guchar *exif_buf = NULL;
|
||||
guint exif_buf_len = 0;
|
||||
|
@ -64,6 +66,14 @@ void gimp_metadata_store_exif (gint32 image_ID,
|
|||
gimp_image_parasite_attach (image_ID, parasite);
|
||||
gimp_parasite_free (parasite);
|
||||
}
|
||||
return_vals = gimp_run_procedure ("plug-in-metadata-decode-exif",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_IMAGE, image_ID,
|
||||
GIMP_PDB_INT32, exif_data->size,
|
||||
GIMP_PDB_INT8ARRAY, exif_data,
|
||||
GIMP_PDB_END);
|
||||
if (return_vals[0].data.d_status != GIMP_PDB_SUCCESS)
|
||||
g_warning ("JPEG Exif -> XMP Merge failed");
|
||||
|
||||
free (exif_buf);
|
||||
}
|
||||
|
|
|
@ -30,11 +30,11 @@ metadata_SOURCES = \
|
|||
xmp-encode.h \
|
||||
xmp-encode.c \
|
||||
xmp-schemas.h \
|
||||
xmp-schemas.c
|
||||
# interface.h \
|
||||
# interface.c \
|
||||
# exif-decode.h \
|
||||
# exif-decode.c \
|
||||
xmp-schemas.c \
|
||||
interface.h \
|
||||
interface.c \
|
||||
exif-decode.h \
|
||||
exif-decode.c
|
||||
# exif-encode.h \
|
||||
# exif-encode.c \
|
||||
# iptc-decode.h \
|
||||
|
@ -56,10 +56,12 @@ INCLUDES = \
|
|||
|
||||
LDADD = \
|
||||
$(libgimp) \
|
||||
$(libgimpui) \
|
||||
$(libgimpconfig) \
|
||||
$(libgimpcolor) \
|
||||
$(libgimpbase) \
|
||||
$(libgimpmath) \
|
||||
$(EXIF_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(RT_LIBS) \
|
||||
$(INTLLIBS)
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/* exif-decode.c - decodes exif data and converts it to XMP
|
||||
*
|
||||
* Copyright (C) 2004-2005, Róman Joost <romanofski@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include <libexif/exif-data.h>
|
||||
|
||||
#include "xmp-model.h"
|
||||
#include "xmp-schemas.h"
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
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");
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
exif_foreach_content_cb (ExifContent *content,
|
||||
XMPModel *xmp_model)
|
||||
{
|
||||
exif_content_foreach_entry (content, (void *) exif_foreach_entry_cb, xmp_model);
|
||||
}
|
||||
|
||||
static void
|
||||
exif_foreach_entry_cb (ExifEntry *entry,
|
||||
XMPModel *xmp_model)
|
||||
{
|
||||
g_printerr ("\nWuff! Wuff!:");
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/* exif-decode.h - decode exif data and convert it to XMP
|
||||
*
|
||||
* Copyright (C) 2008, Róman Joost <romanofski@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef EXIF_DECODE_H
|
||||
#define EXIF_DECODE_H
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean exif_merge_to_xmp (XMPModel *xmp_model,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
gboolean xmp_merge_from_exifbuffer (XMPModel *xmp_model,
|
||||
gint32 image_ID,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* EXIF_DECODE_H */
|
|
@ -23,14 +23,16 @@
|
|||
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include <libexif/exif-data.h>
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
#include "metadata.h"
|
||||
#include "xmp-encode.h"
|
||||
|
||||
/* FIXME: uncomment when these are working
|
||||
#include "interface.h"
|
||||
#include "exif-decode.h"
|
||||
/* FIXME: uncomment when these are working
|
||||
#include "exif-encode.h"
|
||||
#include "iptc-decode.h"
|
||||
*/
|
||||
|
@ -65,14 +67,12 @@ MAIN ()
|
|||
static void
|
||||
query (void)
|
||||
{
|
||||
/* FIXME: uncomment when these are working
|
||||
static const GimpParamDef editor_args[] =
|
||||
{
|
||||
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
||||
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)" }
|
||||
};
|
||||
*/
|
||||
|
||||
static const GimpParamDef decode_xmp_args[] =
|
||||
{
|
||||
|
@ -89,7 +89,6 @@ query (void)
|
|||
{ GIMP_PDB_STRING, "xmp", "XMP packet" }
|
||||
};
|
||||
|
||||
/* FIXME: uncomment when these are working
|
||||
static const GimpParamDef decode_exif_args[] =
|
||||
{
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
||||
|
@ -97,6 +96,7 @@ query (void)
|
|||
{ GIMP_PDB_INT8ARRAY, "exif", "EXIF block" }
|
||||
};
|
||||
|
||||
/* FIXME: uncomment when these are working
|
||||
static const GimpParamDef encode_exif_args[] =
|
||||
{
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image" }
|
||||
|
@ -179,17 +179,16 @@ query (void)
|
|||
{ GIMP_PDB_INT32, "overwrite", "Overwrite existing file: { FALSE (0), TRUE (1) }" }
|
||||
};
|
||||
|
||||
/* FIXME: uncomment when these are working
|
||||
gimp_install_procedure (EDITOR_PROC,
|
||||
N_("View and edit metadata (EXIF, IPTC, XMP)"),
|
||||
N_("View and edit metadata (EXIF, IPTC, XMP)"),
|
||||
"View and edit metadata information attached to the "
|
||||
"current image. This can include EXIF, IPTC and/or "
|
||||
"XMP information. Some or all of this metadata "
|
||||
"will be saved in the file, depending on the output "
|
||||
"file format.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2004-2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2004-2005",
|
||||
N_("Propert_ies"),
|
||||
"RGB*, INDEXED*, GRAY*",
|
||||
GIMP_PLUGIN,
|
||||
|
@ -197,18 +196,17 @@ query (void)
|
|||
editor_args, NULL);
|
||||
|
||||
gimp_plugin_menu_register (EDITOR_PROC, "<Image>/File/Info");
|
||||
gimp_plugin_icon_register (EDITOR_PROC, GIMP_ICON_TYPE_STOCK_ID,
|
||||
*/
|
||||
// XXX gimp_plugin_icon_register (EDITOR_PROC, GIMP_ICON_TYPE_STOCK_ID,
|
||||
|
||||
gimp_install_procedure (DECODE_XMP_PROC,
|
||||
"Decode an XMP packet",
|
||||
"Decode an XMP packet",
|
||||
"Parse an XMP packet and merge the results with "
|
||||
"any metadata already attached to the image. This "
|
||||
"should be used when an XMP packet is read from an "
|
||||
"image file.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -216,13 +214,13 @@ query (void)
|
|||
decode_xmp_args, NULL);
|
||||
|
||||
gimp_install_procedure (ENCODE_XMP_PROC,
|
||||
"Encode metadata into an XMP packet",
|
||||
"Encode metadata into an XMP packet",
|
||||
"Generate an XMP packet from the metadata "
|
||||
"information attached to the image. The new XMP "
|
||||
"packet can then be saved into a file.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Róman Joost <romanofski@gimp.org>",
|
||||
"Róman Joost <romanofski@gimp.org>",
|
||||
"2008",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -230,30 +228,30 @@ query (void)
|
|||
G_N_ELEMENTS (encode_xmp_return_vals),
|
||||
encode_xmp_args, encode_xmp_return_vals);
|
||||
|
||||
/* FIXME: uncomment when these are working
|
||||
gimp_install_procedure (DECODE_EXIF_PROC,
|
||||
"Decode an EXIF block",
|
||||
"Decode an EXIF block",
|
||||
"Parse an EXIF block and merge the results with "
|
||||
"any metadata already attached to the image. This "
|
||||
"should be used when an EXIF block is read from an "
|
||||
"image file.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (decode_exif_args), 0,
|
||||
decode_exif_args, NULL);
|
||||
|
||||
/* FIXME: uncomment when these are working
|
||||
gimp_install_procedure (ENCODE_EXIF_PROC,
|
||||
"Encode metadata into an EXIF block",
|
||||
"Encode metadata into an EXIF block",
|
||||
"Generate an EXIF block from the metadata "
|
||||
"information attached to the image. The new EXIF "
|
||||
"block can then be saved into a file.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -263,12 +261,12 @@ query (void)
|
|||
*/
|
||||
|
||||
gimp_install_procedure (GET_PROC,
|
||||
"Retrieve the values of an XMP property",
|
||||
"Retrieve the values of an XMP property",
|
||||
"Retrieve the list of values associated with "
|
||||
"an XMP property.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -277,13 +275,13 @@ query (void)
|
|||
get_args, get_return_vals);
|
||||
|
||||
gimp_install_procedure (SET_PROC,
|
||||
"Set the values of an XMP property",
|
||||
"Set the values of an XMP property",
|
||||
"Set the list of values associated with "
|
||||
"an XMP property. If a property with the same "
|
||||
"name already exists, it will be replaced.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -291,15 +289,15 @@ query (void)
|
|||
set_args, NULL);
|
||||
|
||||
gimp_install_procedure (GET_SIMPLE_PROC,
|
||||
"Retrieve the value of an XMP property",
|
||||
"Retrieve the value of an XMP property",
|
||||
"Retrieve value associated with a scalar XMP "
|
||||
"property. This can only be done for simple "
|
||||
"property types such as text or integers. "
|
||||
"Structured types must be retrieved with "
|
||||
"plug_in_metadata_get().",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -308,14 +306,14 @@ query (void)
|
|||
get_simple_args, get_simple_return_vals);
|
||||
|
||||
gimp_install_procedure (SET_SIMPLE_PROC,
|
||||
"Set the value of an XMP property",
|
||||
"Set the value of an XMP property",
|
||||
"Set the value of a scalar XMP property. This "
|
||||
"can only be done for simple property types such "
|
||||
"as text or integers. Structured types need to "
|
||||
"be set with plug_in_metadata_set().",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -323,14 +321,14 @@ query (void)
|
|||
set_simple_args, NULL);
|
||||
|
||||
gimp_install_procedure (IMPORT_PROC,
|
||||
"Import XMP from a file into the current image",
|
||||
"Import XMP from a file into the current image",
|
||||
"Load an XMP packet from a file and import it into "
|
||||
"the current image. This can be used to add a "
|
||||
"license statement or some other predefined "
|
||||
"metadata to an image",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -338,16 +336,16 @@ query (void)
|
|||
import_args, NULL);
|
||||
|
||||
gimp_install_procedure (EXPORT_PROC,
|
||||
"Export XMP from the current image to a file",
|
||||
"Export XMP from the current image to a file",
|
||||
"Export the metadata associated with the current "
|
||||
"image into a file. The metadata will be saved as "
|
||||
"an XMP packet. If overwrite is TRUE, then any "
|
||||
"existing file will be overwritten without warning. "
|
||||
"If overwrite is FALSE, then an error will occur if "
|
||||
"the file already exists.",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"Raphaël Quinet <raphael@gimp.org>",
|
||||
"2005",
|
||||
NULL,
|
||||
NULL,
|
||||
GIMP_PLUGIN,
|
||||
|
@ -388,6 +386,7 @@ run (const gchar *name,
|
|||
if (parasite)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_warning ("Parsing Metadata XMP parasite.");
|
||||
|
||||
if (!! strncmp (gimp_parasite_data (parasite),
|
||||
METADATA_MARKER, METADATA_MARKER_LEN)
|
||||
|
@ -396,7 +395,7 @@ run (const gchar *name,
|
|||
+ METADATA_MARKER_LEN,
|
||||
gimp_parasite_data_size (parasite)
|
||||
- METADATA_MARKER_LEN,
|
||||
FALSE, &error))
|
||||
TRUE, &error))
|
||||
{
|
||||
g_printerr ("Metadata parasite seems to be corrupt");
|
||||
/* continue anyway, we will attach a clean parasite later */
|
||||
|
@ -432,11 +431,23 @@ run (const gchar *name,
|
|||
if (! xmp_model_parse_buffer (xmp_model, buffer, strlen (buffer),
|
||||
FALSE, &error))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
}
|
||||
else if (! strcmp (name, ENCODE_XMP_PROC))
|
||||
{
|
||||
/* done below together with the parasite */
|
||||
}
|
||||
else if (! strcmp (name, DECODE_EXIF_PROC))
|
||||
{
|
||||
#ifdef HAVE_EXIF
|
||||
GError *error = NULL;
|
||||
|
||||
if (! xmp_merge_from_exifbuffer (xmp_model,
|
||||
image_ID,
|
||||
&error))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
#endif
|
||||
}
|
||||
else if (! strcmp (name, GET_PROC))
|
||||
{
|
||||
g_printerr ("Not implemented yet (GET_PROC)\n"); /* FIXME */
|
||||
|
@ -509,7 +520,6 @@ run (const gchar *name,
|
|||
}
|
||||
else if (! strcmp (name, EDITOR_PROC))
|
||||
{
|
||||
/* FIXME: uncomment when these are working
|
||||
GimpRunMode run_mode;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
@ -519,7 +529,6 @@ run (const gchar *name,
|
|||
status = GIMP_PDB_CANCEL;
|
||||
}
|
||||
|
||||
*/
|
||||
g_printerr ("Not implemented yet (EDITOR_PROC)\n");
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue