gthumb r2166 - in trunk: . libgthumb src
- From: mjc svn gnome org
- To: svn-commits-list gnome org
- Subject: gthumb r2166 - in trunk: . libgthumb src
- Date: Sun, 6 Jan 2008 15:27:08 +0000 (GMT)
Author: mjc
Date: Sun Jan 6 15:27:08 2008
New Revision: 2166
URL: http://svn.gnome.org/viewvc/gthumb?rev=2166&view=rev
Log:
2008-01-06 Michael J. Chudobiak <mjc svn gnome org>
* NEWS:
* configure.in:
* libgthumb/Makefile.am:
* libgthumb/gth-exif-utils.c: (gth_read_exiv2):
* libgthumb/gth-exif-utils.h:
* libgthumb/gth-exiv2-utils.cpp:
* libgthumb/gth-exiv2-utils.hpp:
* src/gth-exif-data-viewer.c: (update_metadata):
Initial support for the exiv2 metadata-reading library.
Tweaked version of patch by SchmeisserMartin, via ghop.
http://code.google.com/p/google-highly-open-participation-gnome/issues/detail?id=83
Needs some work to improve categorization and output formatting.
Added:
trunk/libgthumb/gth-exiv2-utils.cpp
trunk/libgthumb/gth-exiv2-utils.hpp
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/configure.in
trunk/libgthumb/Makefile.am
trunk/libgthumb/gth-exif-utils.c
trunk/libgthumb/gth-exif-utils.h
trunk/src/gth-exif-data-viewer.c
Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog (original)
+++ trunk/ChangeLog Sun Jan 6 15:27:08 2008
@@ -1,3 +1,18 @@
+2008-01-06 Michael J. Chudobiak <mjc svn gnome org>
+
+ * NEWS:
+ * configure.in:
+ * libgthumb/Makefile.am:
+ * libgthumb/gth-exif-utils.c: (gth_read_exiv2):
+ * libgthumb/gth-exif-utils.h:
+ * libgthumb/gth-exiv2-utils.cpp:
+ * libgthumb/gth-exiv2-utils.hpp:
+ * src/gth-exif-data-viewer.c: (update_metadata):
+ Initial support for the exiv2 metadata-reading library.
+ Tweaked version of patch by SchmeisserMartin, via ghop.
+ http://code.google.com/p/google-highly-open-participation-gnome/issues/detail?id=83
+ Needs some work to improve categorization and output formatting.
+
2008-01-04 Michael J. Chudobiak <mjc svn gnome org>
* NEWS:
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sun Jan 6 15:27:08 2008
@@ -54,6 +54,7 @@
* Added a Flickr uploader (by launching Postr). Bug #489403.
* Added user prompts to the scripting feature.
* Added strftime format codes to the scripting feature.
+ * Initial support for the exiv2 metadata-reading library.
version 2.10.8
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Sun Jan 6 15:27:08 2008
@@ -36,6 +36,7 @@
BONOBO_REQUIRED=2.6.0
LIBOPENRAW_REQUIRED=0.0.2
EXEMPI_REQUIRED=1.99.2
+EXIV2_REQUIRED=0.15
GSTREAMER_REQUIRED=0.10.0
AC_SUBST(GLIB_REQUIRED)
@@ -52,6 +53,7 @@
AC_SUBST(BONOBO_REQUIRED)
AC_SUBST(LIBOPENRAW_REQUIRED)
AC_SUBST(EXEMPI_REQUIRED)
+AC_SUBST(EXIV2_REQUIRED)
AC_SUBST(GSTREAMER_REQUIRED)
AM_PATH_ORBIT2
@@ -262,6 +264,21 @@
#
+# check for exiv2
+#
+AC_ARG_ENABLE([exiv2],
+ [AC_HELP_STRING([--disable-exiv2], [Disable exiv2 metadata extraction])],,
+ [enable_exiv2=yes])
+HAVE_EXIV2=no
+if test "x$enable_exiv2" = "xyes"; then
+ PKG_CHECK_MODULES(EXIV2, exiv2 >= $EXIV2_REQUIRED,
+ [AC_DEFINE(HAVE_EXIV2, 1, [Define to 1 to enable exiv2 support])
+ HAVE_EXIV2=yes],
+ [HAVE_EXIV2=no])
+fi
+
+
+#
# check for gstreamer
#
AC_ARG_ENABLE([gstreamer],
@@ -399,7 +416,8 @@
Have libtiff: ${HAVE_TIFF}
Have libgphoto: ${HAVE_GPHOTO2}
Have libopenraw: ${HAVE_LIBOPENRAW}
- Have exempi: ${HAVE_EXEMPI}
+ Have exempi: ${HAVE_EXEMPI}
+ Have exiv2: ${HAVE_EXIV2}
Have gstreamer: ${HAVE_GSTREAMER}
"
Modified: trunk/libgthumb/Makefile.am
==============================================================================
--- trunk/libgthumb/Makefile.am (original)
+++ trunk/libgthumb/Makefile.am Sun Jan 6 15:27:08 2008
@@ -16,6 +16,7 @@
-DGTHUMB_GLADEDIR=\""$(gladedir)"\" \
$(LIBOPENRAW_CFLAGS) \
$(EXEMPI_CFLAGS) \
+ $(EXIV2_CFLAGS) \
$(GSTREAMER_CFLAGS) \
$(DISABLE_DEPRECATED)
@@ -47,6 +48,7 @@
glib-utils.h \
gstringlist.h \
gth-exif-utils.h \
+ gth-exiv2-utils.hpp \
gth-filter.h \
gth-image-list.h \
gth-iviewer.h \
@@ -105,6 +107,7 @@
glib-utils.c \
gstringlist.c \
gth-exif-utils.c \
+ gth-exiv2-utils.cpp \
gth-filter.c \
gth-pixbuf-op.c \
gth-image-list.c \
@@ -145,6 +148,7 @@
$(IPTCDATA_LIBS) \
$(LIBOPENRAW_LIBS) \
$(EXEMPI_LIBS) \
+ $(EXIV2_LIBS) \
$(GSTREAMER_LIBS)
gthumb-marshal.h: gthumb-marshal.list $(GLIB_GENMARSHAL)
Modified: trunk/libgthumb/gth-exif-utils.c
==============================================================================
--- trunk/libgthumb/gth-exif-utils.c (original)
+++ trunk/libgthumb/gth-exif-utils.c Sun Jan 6 15:27:08 2008
@@ -987,4 +987,30 @@
return metadata;
}
+GList * read_exiv2_file (const char *uri, GList *metadata);
+
+GList *
+gth_read_exiv2 (const char *uri, GList *metadata)
+{
+#ifdef HAVE_EXIV2
+ char *local_file;
+
+ local_file = get_cache_filename_from_uri (uri);
+ if (local_file == NULL)
+ return metadata;
+
+ /* Because prepending is faster than appending */
+ metadata = g_list_reverse (metadata);
+
+ metadata = read_exiv2_file (local_file, metadata);
+
+ /* Undo the initial reverse */
+ metadata = g_list_reverse (metadata);
+
+ g_free (local_file);
+#endif
+
+ return metadata;
+}
+
Modified: trunk/libgthumb/gth-exif-utils.h
==============================================================================
--- trunk/libgthumb/gth-exif-utils.h (original)
+++ trunk/libgthumb/gth-exif-utils.h Sun Jan 6 15:27:08 2008
@@ -56,6 +56,7 @@
GTH_METADATA_CATEGORY_VERSIONS,
GTH_METADATA_CATEGORY_XMP_EMBEDDED,
GTH_METADATA_CATEGORY_XMP_SIDECAR,
+ GTH_METADATA_CATEGORY_EXIV2,
GTH_METADATA_CATEGORY_GSTREAMER,
GTH_METADATA_CATEGORY_OTHER,
GTH_METADATA_CATEGORIES
@@ -97,6 +98,8 @@
GthTransform transform);
GList * gth_read_xmp (const char *filename,
GList *metadata);
+GList * gth_read_exiv2 (const char *filename,
+ GList *metadata);
void free_metadata (GList *metadata);
#endif /* EXIF_UTILS_H */
Added: trunk/libgthumb/gth-exiv2-utils.cpp
==============================================================================
--- (empty file)
+++ trunk/libgthumb/gth-exiv2-utils.cpp Sun Jan 6 15:27:08 2008
@@ -0,0 +1,98 @@
+/* -*- Mode: CPP; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2003 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include "gth-exiv2-utils.hpp"
+
+#include <exiv2/image.hpp>
+#include <exiv2/exif.hpp>
+#include <iostream>
+
+inline static GList *
+add (GList *metadata,
+ const gchar *path,
+ const gchar *value,
+ GthMetadataCategory category)
+{
+ GthMetadata *new_entry;
+
+ new_entry = g_new (GthMetadata, 1);
+ new_entry->category = category;
+ new_entry->name = g_strdup (path);
+ new_entry->value = g_strdup (value);
+ new_entry->position = 0;
+ metadata = g_list_prepend (metadata, new_entry);
+
+ return metadata;
+}
+
+/*
+ * read_exif2_file
+ * reads metadata from image files
+ * code relies heavily on example1 from the exiv2 website
+ * http://www.exiv2.org/example1.html
+ */
+extern "C"
+GList *
+read_exiv2_file (const char *uri, GList *metadata)
+{
+ try {
+ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(uri);
+ if (image.get() == 0) {
+ metadata = add(metadata, "Failed to open file.", "could not open file to read metadata.", GTH_METADATA_CATEGORY_OTHER);
+ return metadata;
+ }
+ image->readMetadata();
+
+ Exiv2::ExifData &exifData = image->exifData();
+
+ //abort if no data found
+ if (exifData.empty()) {
+ metadata = add(metadata, "No metadata found.", "could not find any EXIF metadata in the file", GTH_METADATA_CATEGORY_OTHER);
+ return metadata;
+ }
+
+ //add metadata to glist
+ GthMetadata *new_entry;
+ for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != exifData.end(); ++i) {
+ //determine metadata category
+ GthMetadataCategory cat;
+ switch (i->ifdId ()) {
+ //case Exiv2::ifd0Id : cat = GTH_METADATA_CATEGORY_EXIF_IMAGE; break;
+ //case Exiv2::exifIfdId : cat = GTH_METADATA_CATEGORY_EXIF_IMAGE; break;
+ //case Exiv2::iopIfdId : cat = GTH_METADATA_CATEGORY_VERSIONS; break;
+ //case Exiv2::gpsIfdId : cat = GTH_METADATA_CATEGORY_GPS; break;
+ //default : cat = GTH_METADATA_CATEGORY_OTHER; break;
+ default : cat = GTH_METADATA_CATEGORY_EXIV2; break;
+ }
+ //fill entry
+ //metadata = add(metadata, i->tagName().c_str(), i->toString().c_str(), cat);
+ metadata = add (metadata, i->key().c_str(), i->toString().c_str(), cat);
+ }
+
+ return metadata;
+ }
+ catch (Exiv2::AnyError& e) {
+ std::cerr << "Caught Exiv2 exception '" << e << "'\n";
+ return metadata;
+ }
+}
+
Added: trunk/libgthumb/gth-exiv2-utils.hpp
==============================================================================
--- (empty file)
+++ trunk/libgthumb/gth-exiv2-utils.hpp Sun Jan 6 15:27:08 2008
@@ -0,0 +1,32 @@
+/* -*- Mode: CPP; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2003 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GHT_EXIV2_UTILS_HPP
+#define GHT_EXIV2_UTILS_HPP
+
+#include "gth-exif-utils.h"
+
+extern "C" GList *
+read_exiv2_file (const char *uri, GList *metadata);
+
+#endif
+
Modified: trunk/src/gth-exif-data-viewer.c
==============================================================================
--- trunk/src/gth-exif-data-viewer.c (original)
+++ trunk/src/gth-exif-data-viewer.c Sun Jan 6 15:27:08 2008
@@ -59,6 +59,7 @@
N_("Exif Versions"),
N_("XMP Embedded"),
N_("XMP Sidecar"),
+ N_("Exiv2 Experimental"),
N_("Audio / Video"),
N_("Other")
};
@@ -794,7 +795,13 @@
if (uri == NULL)
return metadata;
- if (mime_type_is (mime_type, "image/jpeg"))
+/* for now, use both exiv2 and libexif, until we're more comfortable with exiv2 */
+#ifdef HAVE_EXIV2
+ if ( mime_type_is (mime_type, "image/jpeg") || mime_type_is (mime_type, "image/tiff") || mime_type_is (mime_type, "image/png"))
+ metadata = gth_read_exiv2 (uri, metadata);
+#endif
+
+ if ( mime_type_is (mime_type, "image/jpeg"))
metadata = gth_read_exif (uri, metadata, existing_edata);
metadata = gth_read_xmp (uri, metadata);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]