[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9773 - in Extractor: . src/include src/main src/plugins
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9773 - in Extractor: . src/include src/main src/plugins |
Date: |
Tue, 15 Dec 2009 21:45:08 +0100 |
Author: grothoff
Date: 2009-12-15 21:45:08 +0100 (Tue, 15 Dec 2009)
New Revision: 9773
Added:
Extractor/src/plugins/thumbnailgtk_extractor.c
Removed:
Extractor/src/plugins/thumbnail/
Modified:
Extractor/configure.ac
Extractor/src/include/extractor.h
Extractor/src/main/extractor_metatypes.c
Extractor/src/plugins/Makefile.am
Log:
thumbnailgtk
Modified: Extractor/configure.ac
===================================================================
--- Extractor/configure.ac 2009-12-15 19:23:40 UTC (rev 9772)
+++ Extractor/configure.ac 2009-12-15 20:45:08 UTC (rev 9773)
@@ -560,7 +560,6 @@
src/plugins/oo/Makefile
src/plugins/printable/Makefile
src/plugins/hash/Makefile
-src/plugins/thumbnail/Makefile
src/plugins/thumbnailffmpeg/Makefile
src/test/Makefile
])
Modified: Extractor/src/include/extractor.h
===================================================================
--- Extractor/src/include/extractor.h 2009-12-15 19:23:40 UTC (rev 9772)
+++ Extractor/src/include/extractor.h 2009-12-15 20:45:08 UTC (rev 9773)
@@ -240,10 +240,10 @@
EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE = 113,
+ EXTRACTOR_METATYPE_THUMBNAIL = 114,
/* fixme: used up to here! */
- EXTRACTOR_METATYPE_THUMBNAIL_DATA = 70,
EXTRACTOR_METATYPE_RESOLUTION = 57,
EXTRACTOR_METATYPE_SCALE = 108,
Modified: Extractor/src/main/extractor_metatypes.c
===================================================================
--- Extractor/src/main/extractor_metatypes.c 2009-12-15 19:23:40 UTC (rev
9772)
+++ Extractor/src/main/extractor_metatypes.c 2009-12-15 20:45:08 UTC (rev
9773)
@@ -287,8 +287,19 @@
creator and the software producer? PDF and DVI
both have this distinction (i.e., Writer vs.
OpenOffice) */
+ { gettext_noop ("thumbnail"),
+ gettext_noop ("smaller version of the image for previewing") },
+ /* 115 */
{ gettext_noop (""),
gettext_noop ("") },
+ { gettext_noop (""),
+ gettext_noop ("") },
+ { gettext_noop (""),
+ gettext_noop ("") },
+ { gettext_noop (""),
+ gettext_noop ("") },
+ { gettext_noop (""),
+ gettext_noop ("") },
#if 0
gettext_noop("author"),
Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am 2009-12-15 19:23:40 UTC (rev 9772)
+++ Extractor/src/plugins/Makefile.am 2009-12-15 20:45:08 UTC (rev 9773)
@@ -16,7 +16,7 @@
oledir=ole2
endif
if HAVE_GTK
-thumbgtk=thumbnail
+ thumbgtk=libextractor_thumbnailgtk.la
endif
endif
@@ -93,7 +93,8 @@
libextractor_it.la \
libextractor_mime.la \
$(pdf) \
- $(rpm)
+ $(rpm) \
+ $(thumbgtk)
libextractor_applefile_la_SOURCES = \
applefile_extractor.c
@@ -166,6 +167,14 @@
libextractor_rpm_la_LIBADD = \
-lrpm
+libextractor_thumbnailgtk_la_CFLAGS = \
+ $(GLIB_CFLAGS) $(GTK_CFLAGS)
+libextractor_thumbnailgtk_la_LIBADD = \
+ $(LIBADD) -lgobject-2.0 @GTK_LIBS@
+libextractor_thumbnailgtk_la_LDFLAGS = \
+ $(PLUGINFLAGS)
+libextractor_thumbnailgtk_la_SOURCES = \
+ thumbnailgtk_extractor.c
Copied: Extractor/src/plugins/thumbnailgtk_extractor.c (from rev 9771,
Extractor/src/plugins/thumbnail/thumbnailextractor.c)
===================================================================
--- Extractor/src/plugins/thumbnailgtk_extractor.c
(rev 0)
+++ Extractor/src/plugins/thumbnailgtk_extractor.c 2009-12-15 20:45:08 UTC
(rev 9773)
@@ -0,0 +1,148 @@
+/*
+ This file is part of libextractor.
+ (C) 2005, 2009 Vidyut Samanta and Christian Grothoff
+
+ libextractor 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, or (at your
+ option) any later version.
+
+ libextractor 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 libextractor; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file thumbnailextractor.c
+ * @author Christian Grothoff
+ * @brief this extractor produces a binary (!) encoded
+ * thumbnail of images (using gdk pixbuf). The bottom
+ * of the file includes a decoder method that can be used
+ * to reproduce the 128x128 PNG thumbnails.
+ */
+
+#include "platform.h"
+#include "extractor.h"
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#define THUMBSIZE 128
+
+/* using libgobject, needs init! */
+void __attribute__ ((constructor)) ole_gobject_init ()
+{
+ g_type_init ();
+}
+
+
+int
+EXTRACTOR_thumbnailgtk_extract (const char *data,
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
+{
+ GdkPixbufLoader *loader;
+ GdkPixbuf *in;
+ GdkPixbuf *out;
+ size_t length;
+ char *thumb;
+ unsigned long width;
+ unsigned long height;
+ char format[64];
+ int ret;
+
+ loader = gdk_pixbuf_loader_new ();
+ gdk_pixbuf_loader_write (loader,
+ (const unsigned char*) data,
+ size, NULL);
+ in = gdk_pixbuf_loader_get_pixbuf (loader);
+ gdk_pixbuf_loader_close (loader, NULL);
+ if (in == NULL)
+ {
+ g_object_unref (loader);
+ return 0;
+ }
+ g_object_ref (in);
+ g_object_unref (loader);
+ height = gdk_pixbuf_get_height (in);
+ width = gdk_pixbuf_get_width (in);
+ snprintf (format,
+ sizeof(format),
+ "%ux%u",
+ (unsigned int) width,
+ (unsigned int) height);
+ if (0 != proc (proc_cls,
+ "thumbnailgtk",
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ format,
+ strlen (format) + 1))
+ {
+ g_object_unref (in);
+ return 1;
+ }
+ if ((height <= THUMBSIZE) && (width <= THUMBSIZE))
+ {
+ g_object_unref (in);
+ return 0;
+ }
+ if (height > THUMBSIZE)
+ {
+ width = width * THUMBSIZE / height;
+ height = THUMBSIZE;
+ }
+ if (width > THUMBSIZE)
+ {
+ height = height * THUMBSIZE / width;
+ width = THUMBSIZE;
+ }
+ if ( (height == 0) || (width == 0) )
+ {
+ g_object_unref (in);
+ return 0;
+ }
+ out = gdk_pixbuf_scale_simple (in, width, height, GDK_INTERP_BILINEAR);
+ g_object_unref (in);
+ thumb = NULL;
+ length = 0;
+ if (out == NULL)
+ return 0;
+ if (!gdk_pixbuf_save_to_buffer (out, &thumb, &length, "png", NULL,
+ "compression", "9", NULL))
+ {
+ g_object_unref (out);
+ return 0;
+ }
+ g_object_unref (out);
+ if (thumb == NULL)
+ return 0;
+ ret = proc (proc_cls,
+ "thumbnailgtk",
+ EXTRACTOR_METATYPE_THUMBNAIL,
+ EXTRACTOR_METAFORMAT_BINARY,
+ "image/png",
+ thumb, length);
+ free (thumb);
+ return ret;
+}
+
+int
+EXTRACTOR_thumbnail_extract (const char *data,
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
+{
+ return EXTRACTOR_thumbnailgtk_extract (data, size, proc, proc_cls, options);
+}
+
+
+/* end of thumbnailgtk_extractor.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9773 - in Extractor: . src/include src/main src/plugins,
gnunet <=