[gthumb] added a exiv2_clear_metadata function



commit 9ad32f30d86a428d7304432f3a0cc81a569ba224
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Apr 30 22:49:41 2011 +0200

    added a exiv2_clear_metadata function

 extensions/exiv2_tools/exiv2-utils.cpp |   36 ++++++++++++++++++++++++++++++++
 extensions/exiv2_tools/exiv2-utils.h   |    3 ++
 2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
index 7ecc25d..34c7b41 100644
--- a/extensions/exiv2_tools/exiv2-utils.cpp
+++ b/extensions/exiv2_tools/exiv2-utils.cpp
@@ -1143,6 +1143,42 @@ exiv2_write_metadata_to_buffer (void      **buffer,
 }
 
 
+extern "C"
+gboolean
+exiv2_clear_metadata (void   **buffer,
+		      gsize   *buffer_size,
+		      GError **error)
+{
+	try {
+		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
+		g_assert (image.get() != 0);
+
+		try {
+			image->clearMetadata();
+			image->writeMetadata();
+		}
+		catch (Exiv2::AnyError& e) {
+			g_warning ("%s", e.what());
+		}
+
+		Exiv2::BasicIo &io = image->io();
+		io.open();
+		Exiv2::DataBuf buf = io.read(io.size());
+
+		g_free (*buffer);
+		*buffer = g_memdup (buf.pData_, buf.size_);
+		*buffer_size = buf.size_;
+	}
+	catch (Exiv2::AnyError& e) {
+		if (error != NULL)
+			*error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, e.what());
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+
 #define MAX_RATIO_ERROR_TOLERANCE 0.01
 
 
diff --git a/extensions/exiv2_tools/exiv2-utils.h b/extensions/exiv2_tools/exiv2-utils.h
index c65dd26..b15a3c1 100644
--- a/extensions/exiv2_tools/exiv2-utils.h
+++ b/extensions/exiv2_tools/exiv2-utils.h
@@ -44,6 +44,9 @@ gboolean   exiv2_write_metadata_to_buffer   (void           **buffer,
 					     GFileInfo       *info,
 					     GdkPixbuf       *pixbuf, /* optional */
 					     GError         **error);
+gboolean   exiv2_clear_metadata             (void           **buffer,
+					     gsize           *buffer_size,
+					     GError         **error);
 GdkPixbuf *exiv2_generate_thumbnail         (const char      *uri,
 					     const char      *mime_type,
 					     int              size);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]