On 10/3/06, Jamie McCracken <[EMAIL PROTECTED]> wrote:
Edward Duffy wrote:
> On 10/3/06, Jamie McCracken <[EMAIL PROTECTED]> wrote:
>> Edward Duffy wrote:
>> > patch attached.
>> >
>>
>> great but what about comments in gif files?
>>
>> Also whats the problem  with animated gifs? Do they output multiple
>> heights and widths?
> yeah...eg.
> 150x10773x9571x9671x10073x10073x9571x9671x10073x10073x9571x9...
>>
>> cant we use format "W%w\\nH%h\\nC%c"
>>
>> so you can g_strsplit on \n and tell the type by looking at the first
>> char (or whatever else works)
>>
> yeah..that'll probably work... gimme a sec.

oh I dont know if the comment can contain a newline char so best to make
sure you handle that too (unless you know otherwise)

so demanding... ;)

Ok, here it is.  Wasn't sure if tracker handled newlines in strings,
so I called g_strescape on it.  Go ahead and remove it if it's not
nessasary.  But it'll look like this:

Image.Comments=Created with The GIMP\n\nBut with a newline;
Image.Width=640;
Image.Height=480;



--
Mr Jamie McCracken
http://jamiemcc.livejournal.com/

Index: src/tracker-extract/tracker-extract.c
===================================================================
RCS file: /cvs/gnome/tracker/src/tracker-extract/tracker-extract.c,v
retrieving revision 1.12
diff -u -p -r1.12 tracker-extract.c
--- src/tracker-extract/tracker-extract.c	3 Oct 2006 11:37:09 -0000	1.12
+++ src/tracker-extract/tracker-extract.c	3 Oct 2006 15:43:23 -0000
@@ -141,45 +141,43 @@ void tracker_extract_png   (gchar *, GHa
 #ifdef HAVE_LIBEXIF
 void tracker_extract_exif   (gchar *, GHashTable *);
 #endif
+void tracker_extract_imagemagick   (gchar *, GHashTable *);
 
 MimeToExtractor extractors[] = {
    /* Document extractors */
-	{ "application/vnd.oasis.opendocument.text",         tracker_extract_oasis },
-	{ "application/vnd.oasis.opendocument.spreadsheet",  tracker_extract_oasis },
-	{ "application/vnd.oasis.opendocument.graphics",     tracker_extract_oasis },
-	{ "application/vnd.oasis.opendocument.presentation", tracker_extract_oasis },
-	{ "application/postscript",                          tracker_extract_ps    },
+	{ "application/vnd.oasis.opendocument.*",       tracker_extract_oasis       },
+	{ "application/postscript",                     tracker_extract_ps          },
 #ifdef HAVE_POPPLER
-	{ "application/pdf",                                 tracker_extract_pdf   },
+	{ "application/pdf",                            tracker_extract_pdf         },
 #endif
-	{ "application/x-abiword",                           tracker_extract_abw   },
+	{ "application/x-abiword",                      tracker_extract_abw         },
 #ifdef HAVE_LIBGSF
-	{ "application/msword",                              tracker_extract_msoffice   },
-	{ "application/vnd.ms-excel",                        tracker_extract_msoffice   },
-	{ "application/vnd.ms-powerpoint",                   tracker_extract_msoffice   },
+	{ "application/msword",                         tracker_extract_msoffice    },
+	{ "application/vnd.ms-*",                       tracker_extract_msoffice    },
 #endif
 
 
    /* Video extractors */
 #ifdef HAVE_THEORA
-	{ "video/x-theora+ogg",                              tracker_extract_theora   },
+	{ "video/x-theora+ogg",                         tracker_extract_theora      },
 #endif
 
 
    /* Audio extractors */
 #ifdef HAVE_VORBIS
-	{ "audio/x-vorbis+ogg",                              tracker_extract_vorbis   },
+	{ "audio/x-vorbis+ogg",                         tracker_extract_vorbis      },
 #endif
 
 
    /* Image extractors */
 #ifdef HAVE_LIBPNG
-	{ "image/png",                                       tracker_extract_png   },
+	{ "image/png",                                  tracker_extract_png         },
 #endif
 #ifdef HAVE_LIBEXIF
-	{ "image/jpeg",                                       tracker_extract_exif   },
+	{ "image/jpeg",                                 tracker_extract_exif        },
 #endif
-	{ "",                                                NULL                           }
+	{ "image/*",                                    tracker_extract_imagemagick },
+	{ "",                                           NULL                        }
 };
 
 static MetadataFileType
@@ -456,7 +454,7 @@ tracker_get_file_metadata (const char *u
 	if (mime) {
 		MimeToExtractor  *p;
 		for (p = extractors; p->extractor; ++p) {
-			if (strcmp (p->mime, mime) == 0) {
+			if (g_pattern_match_simple (p->mime, mime)) {
 				(*p->extractor)(uri_in_locale, meta_table);
 				return meta_table;
 			}
--- /dev/null	2006-08-05 19:53:54.000000000 -0400
+++ src/tracker-extract/tracker-extract-imagemagick.c	2006-10-03 11:38:24.000000000 -0400
@@ -0,0 +1,39 @@
+
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+
+void
+tracker_extract_imagemagick (gchar *filename, GHashTable *metadata)
+{
+	gchar         *argv[6];
+	gchar         *identify;
+	gchar        **lines;
+
+	argv[0] = g_strdup ("identify");
+	argv[1] = g_strdup ("-format");
+	argv[2] = g_strdup ("%w;\\n%h;\\n%c;\\n");
+	argv[3] = g_strdup ("-ping");
+	argv[4] = g_strdup (filename);
+	argv[5] = NULL;
+
+	if(g_spawn_sync (NULL,
+	                 argv,
+	                 NULL,
+	                 G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
+	                 NULL,
+	                 NULL,
+	                 &identify,
+	                 NULL,
+	                 NULL,
+	                 NULL)) {
+
+		lines = g_strsplit (identify, ";\n", 4);
+		g_hash_table_insert (metadata, g_strdup ("Image.Width"), g_strdup (lines[0]));
+		g_hash_table_insert (metadata, g_strdup ("Image.Height"), g_strdup (lines[1]));
+		g_hash_table_insert (metadata, g_strdup ("Image.Comments"), g_strdup (g_strescape (lines[2], "")));
+	}
+}
+
_______________________________________________
tracker-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/tracker-list

Reply via email to