[gimp/metadata-wip-rebased: 16/20] libgimpbase: add gimp_metadata_new() and stubs to set EXIF and XMP data blobs
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-wip-rebased: 16/20] libgimpbase: add gimp_metadata_new() and stubs to set EXIF and XMP data blobs
- Date: Thu, 24 Oct 2013 21:32:22 +0000 (UTC)
commit c22e1aa0249d560d700b7062e3a40b7ec1500f50
Author: Michael Natterer <mitch gimp org>
Date: Wed Oct 23 22:33:22 2013 +0200
libgimpbase: add gimp_metadata_new() and stubs to set EXIF and XMP data blobs
libgimpbase/gimpbase.def | 3 ++
libgimpbase/gimpmetadata.c | 62 ++++++++++++++++++++++++++++++++++++--------
libgimpbase/gimpmetadata.h | 9 ++++++
3 files changed, 63 insertions(+), 11 deletions(-)
---
diff --git a/libgimpbase/gimpbase.def b/libgimpbase/gimpbase.def
index 6d87e07..8355008 100644
--- a/libgimpbase/gimpbase.def
+++ b/libgimpbase/gimpbase.def
@@ -54,9 +54,12 @@ EXPORTS
gimp_metadata_get_resolution
gimp_metadata_is_tag_supported
gimp_metadata_load_from_file
+ gimp_metadata_new
gimp_metadata_save_to_file
gimp_metadata_serialize
gimp_metadata_set_bits_per_sample
+ gimp_metadata_set_from_exif
+ gimp_metadata_set_from_xmp
gimp_metadata_set_pixel_size
gimp_metadata_set_resolution
gimp_micro_version
diff --git a/libgimpbase/gimpmetadata.c b/libgimpbase/gimpmetadata.c
index cbe5a21..ce2a944 100644
--- a/libgimpbase/gimpmetadata.c
+++ b/libgimpbase/gimpmetadata.c
@@ -127,6 +127,27 @@ static const guint8 wilber_jpg[] =
static const guint wilber_jpg_len = G_N_ELEMENTS (wilber_jpg);
+GimpMetadata *
+gimp_metadata_new (void)
+{
+ GExiv2Metadata *metadata = NULL;
+
+ if (gexiv2_initialize ())
+ {
+ metadata = gexiv2_metadata_new ();
+
+ if (! gexiv2_metadata_open_buf (metadata, wilber_jpg, wilber_jpg_len,
+ NULL))
+ {
+ g_object_unref (metadata);
+
+ return NULL;
+ }
+ }
+
+ return metadata;
+}
+
typedef struct
{
gchar name[1024];
@@ -230,23 +251,14 @@ gimp_metadata_deserialize_error (GMarkupParseContext *context,
GExiv2Metadata *
gimp_metadata_deserialize (const gchar *metadata_xml)
{
- GExiv2Metadata *metadata = NULL;
+ GimpMetadata *metadata;
GMarkupParser markup_parser;
GimpMetadataParseData parse_data;
GMarkupParseContext *context;
g_return_val_if_fail (metadata_xml != NULL, NULL);
- if (gexiv2_initialize ())
- {
- metadata = gexiv2_metadata_new ();
-
- if (! gexiv2_metadata_open_buf (metadata, wilber_jpg, wilber_jpg_len,
- NULL))
- {
- return NULL;
- }
- }
+ metadata = gimp_metadata_new ();
parse_data.metadata = metadata;
@@ -439,6 +451,34 @@ gimp_metadata_save_to_file (GimpMetadata *metadata,
return success;
}
+gboolean
+gimp_metadata_set_from_exif (GimpMetadata *metadata,
+ const guchar *exif_data,
+ gint exif_data_length)
+{
+ g_return_val_if_fail (GEXIV2_IS_METADATA (metadata), FALSE);
+ g_return_val_if_fail (exif_data != NULL, FALSE);
+ g_return_val_if_fail (exif_data_length > 0, FALSE);
+
+ /* TODO */
+
+ return TRUE;
+}
+
+gboolean
+gimp_metadata_set_from_xmp (GimpMetadata *metadata,
+ const guchar *xmp_data,
+ gint xmp_data_length)
+{
+ g_return_val_if_fail (GEXIV2_IS_METADATA (metadata), FALSE);
+ g_return_val_if_fail (xmp_data != NULL, FALSE);
+ g_return_val_if_fail (xmp_data_length > 0, FALSE);
+
+ /* TODO */
+
+ return TRUE;
+}
+
void
gimp_metadata_set_pixel_size (GimpMetadata *metadata,
gint width,
diff --git a/libgimpbase/gimpmetadata.h b/libgimpbase/gimpmetadata.h
index 4f3e215..618d73b 100644
--- a/libgimpbase/gimpmetadata.h
+++ b/libgimpbase/gimpmetadata.h
@@ -39,6 +39,8 @@ typedef enum
} GimpMetadataSaveFlags;
+GimpMetadata * gimp_metadata_new (void);
+
GimpMetadata * gimp_metadata_deserialize (const gchar *metadata_xml);
gchar * gimp_metadata_serialize (GimpMetadata *metadata);
@@ -48,6 +50,13 @@ gboolean gimp_metadata_save_to_file (GimpMetadata *metadata,
GFile *file,
GError **error);
+gboolean gimp_metadata_set_from_exif (GimpMetadata *metadata,
+ const guchar *exif_data,
+ gint exif_data_length);
+gboolean gimp_metadata_set_from_xmp (GimpMetadata *metadata,
+ const guchar *xmp_data,
+ gint xmp_data_length);
+
void gimp_metadata_set_pixel_size (GimpMetadata *metadata,
gint width,
gint height);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]