tracker r2070 - in branches/indexer-split: . src/tracker-extract
- From: mottela svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2070 - in branches/indexer-split: . src/tracker-extract
- Date: Wed, 13 Aug 2008 14:37:51 +0000 (UTC)
Author: mottela
Date: Wed Aug 13 14:37:50 2008
New Revision: 2070
URL: http://svn.gnome.org/viewvc/tracker?rev=2070&view=rev
Log:
Added new jpeg and tiff extractors
Added:
branches/indexer-split/src/tracker-extract/tracker-extract-jpeg.c
branches/indexer-split/src/tracker-extract/tracker-extract-tiff.c
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/configure.ac
branches/indexer-split/src/tracker-extract/Makefile.am
branches/indexer-split/src/tracker-extract/tracker-xmp.c
Modified: branches/indexer-split/configure.ac
==============================================================================
--- branches/indexer-split/configure.ac (original)
+++ branches/indexer-split/configure.ac Wed Aug 13 14:37:50 2008
@@ -664,6 +664,73 @@
AM_CONDITIONAL(HAVE_LIBGSF, test "$have_libgsf" = "yes")
test "$have_libgsf" = "yes" && AC_DEFINE(HAVE_LIBGSF, [], [Define if we have libgsf])
+
+##################################################################
+# Check for libjpeg
+##################################################################
+
+#
+# FIXME This should be package based. Unfortunately in several main
+# distros, it is not.
+#
+
+OLD_CFLAGS="$CFLAGS"
+OLD_LIBS="$LIBS"
+CFLAGS=""
+LIBS=""
+
+AC_ARG_ENABLE(jpeg, AS_HELP_STRING([--disable-jpeg],[Disable jpeg extractor]),,[enable_jpeg=yes])
+if test "x$enable_jpeg" = "xyes"; then
+ AC_CHECK_HEADER(jpeglib.h,
+ AC_CHECK_LIB(jpeg, jpeg_CreateCompress))
+ have_libjpeg=${ac_cv_lib_jpeg_jpeg_CreateCompress:-no}
+ LIBJPEG_CFLAGS="$CFLAGS"
+ LIBJPEG_LIBS="$LIBS"
+ AC_SUBST(LIBJPEG_CFLAGS)
+ AC_SUBST(LIBJPEG_LIBS)
+else
+ have_libjpeg="no (disabled)"
+fi
+
+AM_CONDITIONAL(HAVE_LIBJPEG, test "$have_libjpeg" = "yes")
+test "$have_libjpeg" = "yes" && AC_DEFINE(HAVE_LIBJPEG, [], [Define if we have libjpeg])
+
+CFLAGS="$OLD_CFLAGS"
+LIBS="$OLD_LIBS"
+
+##################################################################
+# Check for libtiff
+##################################################################
+
+#
+# FIXME This should be package based. Unfortunately in several main
+# distros, it is not.
+#
+
+OLD_CFLAGS="$CFLAGS"
+OLD_LIBS="$LIBS"
+CFLAGS=""
+LIBS=""
+
+AC_ARG_ENABLE(tiff, AS_HELP_STRING([--disable-tiff],[Disable tiff extractor]),,[enable_tiff=yes])
+if test "x$enable_tiff" = "xyes"; then
+ AC_CHECK_HEADER(tiff.h,
+ AC_CHECK_LIB(tiff, TIFFOpen))
+ have_libtiff=${ac_cv_lib_tiff_TIFFOpen:-no}
+ LIBTIFF_CFLAGS="$CFLAGS"
+ LIBTIFF_LIBS="$LIBS"
+ AC_SUBST(LIBTIFF_CFLAGS)
+ AC_SUBST(LIBTIFF_LIBS)
+else
+ have_libtiff="no (disabled)"
+fi
+
+AM_CONDITIONAL(HAVE_LIBTIFF, test "$have_libtiff" = "yes")
+test "$have_libtiff" = "yes" && AC_DEFINE(HAVE_LIBTIFF, [], [Define if we have libtiff])
+
+CFLAGS="$OLD_CFLAGS"
+LIBS="$OLD_LIBS"
+
####################################################################
# Check ioprio support
####################################################################
@@ -804,7 +871,8 @@
png: yes
pdf: $have_poppler
- exif (jpeg): $have_libexif
+ jpeg: $have_libjpeg (xmp: $have_exempi exif: $have_libexif)
+ tiff: $have_libtiff (xmp: $have_exempi exif: yes)
ms & openoffice (gsf): $have_libgsf
xml / html formats: $have_libxml2
embedded / sidecar xmp: $have_exempi
Modified: branches/indexer-split/src/tracker-extract/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-extract/Makefile.am (original)
+++ branches/indexer-split/src/tracker-extract/Makefile.am Wed Aug 13 14:37:50 2008
@@ -5,6 +5,8 @@
$(GLIB2_CFLAGS) \
$(GMODULE_CFLAGS) \
$(EXEMPI_CFLAGS) \
+ $(LIBJPEG_CFLAGS) \
+ $(LIBTIFF_CFLAGS) \
$(LIBEXIF_CFLAGS) \
$(LIBGSF_CFLAGS) \
$(LIBXML2_CFLAGS) \
@@ -28,8 +30,12 @@
modules_LTLIBRARIES += libextract-xmp.la
endif
-if HAVE_LIBEXIF
-modules_LTLIBRARIES += libextract-exif.la
+if HAVE_LIBJPEG
+modules_LTLIBRARIES += libextract-jpeg.la
+endif
+
+if HAVE_LIBTIFF
+modules_LTLIBRARIES += libextract-tiff.la
endif
if HAVE_LIBXML2
@@ -94,10 +100,6 @@
libextract_xmp_la_LDFLAGS = $(module_flags)
libextract_xmp_la_LIBADD = $(GLIB2_LIBS) $(EXEMPI_LIBS)
-libextract_exif_la_SOURCES = tracker-extract-exif.c
-libextract_exif_la_LDFLAGS = $(module_flags)
-libextract_exif_la_LIBADD = $(GLIB2_LIBS) $(LIBEXIF_LIBS)
-
libextract_html_la_SOURCES = tracker-extract-html.c
libextract_html_la_LDFLAGS = $(module_flags)
libextract_html_la_LIBADD = $(GLIB2_LIBS) $(LIBXML2_LIBS)
@@ -120,6 +122,17 @@
libextract_xine_la_LDFLAGS = $(module_flags)
libextract_xine_la_LIBADD = $(GLIB2_LIBS) $(XINE_LIBS)
+libextract_jpeg_la_SOURCES = \
+ tracker-extract-jpeg.c \
+ tracker-xmp.c tracker-xmp.h
+libextract_jpeg_la_LDFLAGS = $(module_flags)
+libextract_jpeg_la_LIBADD = $(GLIB2_LIBS) $(LIBJPEG_LIBS) $(LIBEXIF_LIBS) $(EXEMPI_LIBS)
+
+libextract_tiff_la_SOURCES = \
+ tracker-extract-tiff.c \
+ tracker-xmp.c tracker-xmp.h
+libextract_tiff_la_LDFLAGS = $(module_flags)
+libextract_tiff_la_LIBADD = $(GLIB2_LIBS) $(LIBTIFF_LIBS) $(EXEMPI_LIBS)
bin_PROGRAMS = tracker-extract
Added: branches/indexer-split/src/tracker-extract/tracker-extract-jpeg.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/tracker-extract/tracker-extract-jpeg.c Wed Aug 13 14:37:50 2008
@@ -0,0 +1,280 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* Tracker Extract - extracts embedded metadata from files
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <jpeglib.h>
+#include "tracker-extract.h"
+#include "tracker-xmp.h"
+
+#define XMP_NAMESPACE_LENGTH 29
+
+#ifdef HAVE_LIBEXIF
+#include <libexif/exif-data.h>
+
+#define EXIF_DATE_FORMAT "%Y:%m:%d %H:%M:%S"
+
+static gchar *
+date_to_iso8601 (gchar *exif_date)
+{
+ /* ex; date "2007:04:15 15:35:58"
+ To
+ ex. "2007-04-15T17:35:58+0200 where +0200 is localtime
+ */
+ return tracker_generic_date_to_iso8601 (exif_date, EXIF_DATE_FORMAT);
+}
+
+
+static gchar *
+fix_focal_length (gchar *fl)
+{
+ return g_strndup (fl, (strstr (fl, "mm") - fl));
+}
+
+
+static gchar *
+fix_flash (gchar *flash)
+{
+ if (g_str_has_prefix (flash, "No")) {
+ return g_strdup ("0");
+ } else {
+ return g_strdup ("1");
+ }
+}
+
+
+static gchar *
+fix_fnumber (gchar *fn)
+{
+ if (!fn) {
+ return fn;
+ }
+
+ if (fn[0] == 'F') {
+ fn[0] = ' ';
+ } else if (fn[0] == 'f' && fn[1] == '/') {
+ fn[0] = fn[1] = ' ';
+ }
+
+ return fn;
+}
+
+
+static gchar *
+fix_exposure_time (gchar *et)
+{
+ gchar *sep = strchr (et, '/');
+
+ if (sep) {
+ gdouble fraction = g_ascii_strtod (sep + 1, NULL);
+
+ if (fraction > 0.0) {
+ gdouble val = 1.0f / fraction;
+ char buf[G_ASCII_DTOSTR_BUF_SIZE];
+
+ g_ascii_dtostr (buf, sizeof(buf), val);
+ return g_strdup (buf);
+ }
+ }
+
+ return et;
+}
+
+typedef gchar * (*PostProcessor) (gchar *);
+
+typedef struct {
+ ExifTag tag;
+ gchar *name;
+ PostProcessor post;
+} TagType;
+
+
+TagType tags[] = {
+ { EXIF_TAG_PIXEL_Y_DIMENSION, "Image:Height", NULL },
+ { EXIF_TAG_PIXEL_X_DIMENSION, "Image:Width", NULL },
+ { EXIF_TAG_RELATED_IMAGE_WIDTH, "Image:Width", NULL },
+ { EXIF_TAG_DOCUMENT_NAME, "Image:Title", NULL },
+ /* { -1, "Image:Album", NULL }, */
+ { EXIF_TAG_DATE_TIME, "Image:Date", date_to_iso8601 },
+ /* { -1, "Image:Keywords", NULL }, */
+ { EXIF_TAG_ARTIST, "Image:Creator", NULL },
+ { EXIF_TAG_USER_COMMENT, "Image:Comments", NULL },
+ { EXIF_TAG_IMAGE_DESCRIPTION, "Image:Description", NULL },
+ { EXIF_TAG_SOFTWARE, "Image:Software", NULL },
+ { EXIF_TAG_MAKE, "Image:CameraMake", NULL },
+ { EXIF_TAG_MODEL, "Image:CameraModel", NULL },
+ { EXIF_TAG_ORIENTATION, "Image:Orientation", NULL },
+ { EXIF_TAG_EXPOSURE_PROGRAM, "Image:ExposureProgram", NULL },
+ { EXIF_TAG_EXPOSURE_TIME, "Image:ExposureTime", fix_exposure_time },
+ { EXIF_TAG_FNUMBER, "Image:FNumber", fix_fnumber },
+ { EXIF_TAG_FLASH, "Image:Flash", fix_flash },
+ { EXIF_TAG_FOCAL_LENGTH, "Image:FocalLength", fix_focal_length },
+ { EXIF_TAG_ISO_SPEED_RATINGS, "Image:ISOSpeed", NULL },
+ { EXIF_TAG_METERING_MODE, "Image:MeteringMode", NULL },
+ { EXIF_TAG_WHITE_BALANCE, "Image:WhiteBalance", NULL },
+ { EXIF_TAG_COPYRIGHT, "File:Copyright", NULL },
+ { -1, NULL, NULL }
+};
+
+
+#endif
+
+void
+tracker_read_exif (const unsigned char *buffer, size_t len, GHashTable *metadata)
+{
+#ifdef HAVE_LIBEXIF
+
+ ExifData *exif;
+ TagType *p;
+
+ exif = exif_data_new_from_data ((unsigned char *)buffer, len);
+
+ for (p = tags; p->name; ++p) {
+ ExifEntry *entry = exif_data_get_entry (exif, p->tag);
+
+ if (entry) {
+ gchar buffer[1024];
+
+ exif_entry_get_value (entry, buffer, 1024);
+
+ if (p->post) {
+ g_hash_table_insert (metadata, g_strdup (p->name),
+ g_strdup ((*p->post) (buffer)));
+ } else {
+ g_hash_table_insert (metadata, g_strdup (p->name),
+ g_strdup (buffer));
+ }
+ }
+ }
+#endif
+}
+
+
+static void
+tracker_extract_jpeg (const gchar *filename, GHashTable *metadata)
+{
+ struct jpeg_decompress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+
+ struct jpeg_marker_struct *marker;
+
+ FILE * jpeg;
+ gint fd_jpeg;
+
+ if ((fd_jpeg = g_open (filename, O_RDONLY)) == -1) {
+ return;
+ }
+
+ if ((jpeg = fdopen (fd_jpeg, "rb"))) {
+
+ cinfo.err = jpeg_std_error(&jerr);
+ jpeg_create_decompress(&cinfo);
+
+ jpeg_save_markers(&cinfo, JPEG_COM,0xFFFF);
+ jpeg_save_markers(&cinfo, JPEG_APP0+1,0xFFFF);
+
+ jpeg_stdio_src(&cinfo, jpeg);
+
+ (void) jpeg_read_header(&cinfo, TRUE);
+
+ /* FIXME? It is possible that there are markers after SOS,
+ but there shouldn't be. Should we decompress the whole file?
+
+ jpeg_start_decompress(&cinfo);
+ jpeg_finish_decompress(&cinfo);
+
+ jpeg_calc_output_dimensions(&cinfo);
+ */
+
+ g_hash_table_insert (metadata, g_strdup ("Image:Width"),
+ g_strdup_printf ("%u", (unsigned int) cinfo.image_width));
+ g_hash_table_insert (metadata, g_strdup ("Image:Height"),
+ g_strdup_printf ("%u", (unsigned int) cinfo.image_height));
+
+
+ marker = (struct jpeg_marker_struct *) &cinfo.marker_list;
+
+ while(marker) {
+
+ switch (marker->marker) {
+ case JPEG_COM:
+ g_hash_table_insert (metadata, g_strdup ("Image:Comments"),
+ g_strndup ((gchar *)marker->data, marker->data_length));
+ break;
+
+ case JPEG_APP0+1:
+ #if defined(HAVE_LIBEXIF)
+ if (strncmp ("Exif", (gchar *)(marker->data),5) == 0) {
+ tracker_read_exif ((unsigned char *)marker->data, marker->data_length, metadata);
+ }
+ #endif /* HAVE_LIBEXIF */
+
+ #if defined(HAVE_EXEMPI)
+ if (strncmp ("http://ns.adobe.com/xap/1.0/\x00", (char *)(marker->data),XMP_NAMESPACE_LENGTH) == 0) {
+ tracker_read_xmp ((char *)marker->data+XMP_NAMESPACE_LENGTH,
+ marker->data_length-XMP_NAMESPACE_LENGTH,
+ metadata);
+ }
+ #endif /* HAVE_EXEMPI */
+
+ break;
+
+ default:
+ marker = marker->next;
+
+ continue;
+ break;
+ }
+
+ marker = marker->next;
+ }
+
+
+
+ jpeg_destroy_decompress(&cinfo);
+
+ fclose (jpeg);
+ } else {
+ close (fd_jpeg);
+ }
+}
+
+
+TrackerExtractorData data[] = {
+ { "image/jpeg", tracker_extract_jpeg },
+ { NULL, NULL }
+};
+
+
+TrackerExtractorData *
+tracker_get_extractor_data (void)
+{
+ return data;
+}
Added: branches/indexer-split/src/tracker-extract/tracker-extract-tiff.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/tracker-extract/tracker-extract-tiff.c Wed Aug 13 14:37:50 2008
@@ -0,0 +1,241 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* Tracker Extract - extracts embedded metadata from files
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "tracker-extract.h"
+
+#include <glib.h>
+
+#include <tiff.h>
+#include <tiffio.h>
+
+#include "tracker-xmp.h"
+
+#define XMP_NAMESPACE_LENGTH 29
+
+typedef gchar * (*PostProcessor) (gchar *);
+
+typedef enum {
+ TIFF_TAGTYPE_UNDEFINED = 0,
+ TIFF_TAGTYPE_STRING,
+ TIFF_TAGTYPE_UINT16,
+ TIFF_TAGTYPE_UINT32,
+ TIFF_TAGTYPE_DOUBLE
+} TagType;
+
+typedef struct {
+ guint tag;
+ gchar *name;
+ TagType type;
+ PostProcessor post;
+} TiffTag;
+
+#define EXIF_DATE_FORMAT "%Y:%m:%d %H:%M:%S"
+
+static gchar *
+date_to_iso8601 (gchar *exif_date)
+{
+ /* ex; date "2007:04:15 15:35:58"
+ To
+ ex. "2007-04-15T17:35:58+0200 where +0200 is localtime
+ */
+ return tracker_generic_date_to_iso8601 (exif_date, EXIF_DATE_FORMAT);
+}
+
+
+/* FIXME We are missing some */
+TiffTag tags[] = {
+ { TIFFTAG_ARTIST, "Image:Creator", TIFF_TAGTYPE_STRING, NULL },
+ { TIFFTAG_COPYRIGHT, "File:Copyright", TIFF_TAGTYPE_STRING, NULL },
+ { TIFFTAG_DATETIME, "Image:Date", TIFF_TAGTYPE_STRING, NULL },
+ { TIFFTAG_DOCUMENTNAME, "Image:Title", TIFF_TAGTYPE_STRING, NULL },
+ { TIFFTAG_IMAGEDESCRIPTION, "Image:Comments", TIFF_TAGTYPE_STRING, NULL },
+ { TIFFTAG_IMAGEWIDTH, "Image:Width", TIFF_TAGTYPE_UINT32, NULL },
+ { TIFFTAG_IMAGELENGTH, "Image:Height", TIFF_TAGTYPE_UINT32, NULL },
+ { TIFFTAG_MAKE, "Image:CameraMake", TIFF_TAGTYPE_STRING, NULL },
+ { TIFFTAG_MODEL, "Image:CameraModel", TIFF_TAGTYPE_STRING, NULL },
+ { TIFFTAG_ORIENTATION, "Image:Orientation", TIFF_TAGTYPE_UINT16, NULL },
+ { TIFFTAG_SOFTWARE, "Image:Software", TIFF_TAGTYPE_STRING, NULL },
+ { -1, NULL, TIFF_TAGTYPE_UNDEFINED, NULL }
+};
+
+TiffTag exiftags[] = {
+ {EXIFTAG_EXPOSURETIME, "Image:ExposureTime", TIFF_TAGTYPE_DOUBLE, NULL},
+ {EXIFTAG_FNUMBER, "Image:FNumber", TIFF_TAGTYPE_DOUBLE, NULL},
+ {EXIFTAG_EXPOSUREPROGRAM, "Image:ExposureProgram", TIFF_TAGTYPE_UINT16 ,NULL },
+ {EXIFTAG_ISOSPEEDRATINGS, "Image:ISOSpeed",TIFF_TAGTYPE_UINT32, NULL},
+ {EXIFTAG_DATETIMEORIGINAL, "Image:Date", TIFF_TAGTYPE_STRING,date_to_iso8601},
+ {EXIFTAG_METERINGMODE, "Image:MeteringMode", TIFF_TAGTYPE_UINT16, NULL},
+ {EXIFTAG_FLASH, "Image:Flash", TIFF_TAGTYPE_UINT16, NULL},
+ {EXIFTAG_FOCALLENGTH, "Image:FocalLength", TIFF_TAGTYPE_UINT16, NULL},
+ {EXIFTAG_PIXELXDIMENSION, "Image:Width",TIFF_TAGTYPE_UINT32, NULL},
+ {EXIFTAG_PIXELYDIMENSION, "Image:Height", TIFF_TAGTYPE_UINT32,NULL},
+ {EXIFTAG_WHITEBALANCE, "Image:WhiteBalance", TIFF_TAGTYPE_UINT16,NULL},
+ { -1, NULL, TIFF_TAGTYPE_UNDEFINED, NULL }
+};
+
+
+static void
+tracker_extract_tiff (const gchar *filename, GHashTable *metadata)
+{
+ TIFF *image;
+ long exifOffset;
+ gchar *xmpOffset;
+ uint32 size;
+
+ TiffTag *tag;
+
+ gchar buffer[1024];
+ guint16 varui16;
+ guint32 varui32;
+ float vardouble;
+
+
+ if((image = TIFFOpen(filename, "r")) == NULL){
+ g_error("Could not open image\n");
+ return;
+ }
+
+ for (tag = tags; tag->name; ++tag) {
+
+ switch (tag->type) {
+ case TIFF_TAGTYPE_STRING:
+ if (!TIFFGetField(image, tag->tag, &buffer)) {
+ continue;
+ }
+ break;
+ case TIFF_TAGTYPE_UINT16:
+ if (!TIFFGetField(image, tag->tag, &varui32)) {
+ continue;
+ }
+
+ sprintf(buffer,"%i",varui16);
+ break;
+ case TIFF_TAGTYPE_UINT32:
+ if (!TIFFGetField(image, tag->tag, &varui32)) {
+ continue;
+ }
+
+ sprintf(buffer,"%i",varui32);
+ break;
+ case TIFF_TAGTYPE_DOUBLE:
+ if (!TIFFGetField(image, tag->tag, &vardouble)) {
+ continue;
+ }
+
+ sprintf(buffer,"%f",vardouble);
+ break;
+ default:
+ continue;
+ break;
+ }
+
+ if (tag->post) {
+ g_hash_table_insert (metadata, g_strdup (tag->name),
+ g_strdup ((*tag->post) (buffer)));
+ } else {
+ g_hash_table_insert (metadata, g_strdup (tag->name),
+ g_strdup (buffer));
+ }
+ }
+
+ /* FIXME There are problems between XMP data embedded with different tools
+ due to bugs in the original spec (type) */
+
+#ifdef HAVE_EXEMPI
+
+ if (TIFFGetField(image, TIFFTAG_XMLPACKET, &size, &xmpOffset)) {
+ tracker_read_xmp (xmpOffset,
+ size,
+ metadata);
+ }
+
+#endif
+
+ if (TIFFGetField(image, TIFFTAG_EXIFIFD, &exifOffset)) {
+
+ if (TIFFReadEXIFDirectory(image, exifOffset)) {
+
+ for (tag = exiftags; tag->name; ++tag) {
+
+ switch (tag->type) {
+ case TIFF_TAGTYPE_STRING:
+ if (!TIFFGetField(image, tag->tag, &buffer)) {
+ continue;
+ }
+ break;
+ case TIFF_TAGTYPE_UINT16:
+ if (!TIFFGetField(image, tag->tag, &varui32)) {
+ continue;
+ }
+
+ sprintf(buffer,"%i",varui16);
+ break;
+ case TIFF_TAGTYPE_UINT32:
+ if (!TIFFGetField(image, tag->tag, &varui32)) {
+ continue;
+ }
+
+ sprintf(buffer,"%i",varui32);
+ break;
+ case TIFF_TAGTYPE_DOUBLE:
+ if (!TIFFGetField(image, tag->tag, &vardouble)) {
+ continue;
+ }
+
+ sprintf(buffer,"%f",vardouble);
+ break;
+ default:
+ continue;
+ break;
+ }
+
+ if (tag->post) {
+ g_hash_table_insert (metadata, g_strdup (tag->name),
+ g_strdup ((*tag->post) (buffer)));
+ } else {
+ g_hash_table_insert (metadata, g_strdup (tag->name),
+ g_strdup (buffer));
+ }
+ }
+
+ }
+ }
+
+ TIFFClose(image);
+
+}
+
+
+
+
+TrackerExtractorData data[] = {
+ { "image/tiff", tracker_extract_tiff },
+ { NULL, NULL }
+};
+
+
+TrackerExtractorData *
+tracker_get_extractor_data (void)
+{
+ return data;
+}
Modified: branches/indexer-split/src/tracker-extract/tracker-xmp.c
==============================================================================
--- branches/indexer-split/src/tracker-extract/tracker-xmp.c (original)
+++ branches/indexer-split/src/tracker-extract/tracker-xmp.c Wed Aug 13 14:37:50 2008
@@ -159,6 +159,37 @@
else if (strcmp (name, "keywords") == 0) {
tracker_append_string_to_hash_table (metadata, "Image:Keywords", value, append);
}
+ else if (strcmp (name, "subject") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Subject", value, append);
+ }
+ else if (strcmp (name, "publisher") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Publisher", value, append);
+ }
+ else if (strcmp (name, "contributor") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Contributor", value, append);
+ }
+ else if (strcmp (name, "type") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Type", value, append);
+ }
+ else if (strcmp (name, "format") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Format", value, append);
+ }
+ else if (strcmp (name, "identifier") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Identifier", value, append);
+ }
+ else if (strcmp (name, "source") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Source", value, append);
+ }
+ else if (strcmp (name, "language") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Language", value, append);
+ }
+ else if (strcmp (name, "relation") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Relation", value, append);
+ }
+ else if (strcmp (name, "coverage") == 0) {
+ tracker_append_string_to_hash_table (metadata, "DC:Coverage", value, append);
+ }
+
}
/* Creative Commons */
else if (strcmp (schema, NS_CC) == 0) {
@@ -166,6 +197,12 @@
tracker_append_string_to_hash_table (metadata, "File:License", value, append);
}
}
+ /* Exif basic scheme */
+ else if (strcmp (schema, NS_EXIF) == 0) {
+ if (strcmp (name, "title") == 0) {
+ tracker_append_string_to_hash_table (metadata, "Image:Title", value, append);
+ }
+ }
g_free (name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]