#include "platform.h"
#include "extractor.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
Go to the source code of this file.
Defines | |
| #define | THUMBSIZE 128 |
Functions | |
| void | __attribute__ ((constructor)) |
| static EXTRACTOR_KeywordList * | addKeyword (EXTRACTOR_KeywordType type, char *keyword, EXTRACTOR_KeywordList *next) |
| EXTRACTOR_Keywords * | libextractor_thumbnailgtk_extract (const char *filename, const unsigned char *data, size_t size, struct EXTRACTOR_Keywords *prev) |
| EXTRACTOR_Keywords * | libextractor_thumbnail_extract (const char *filename, const unsigned char *data, size_t size, struct EXTRACTOR_Keywords *prev, const char *options) |
Variables | |
| static char * | whitelist [] |
Definition in file thumbnailextractor.c.
| #define THUMBSIZE 128 |
Definition at line 34 of file thumbnailextractor.c.
Referenced by libextractor_thumbnailgtk_extract().
| void __attribute__ | ( | (constructor) | ) |
| static EXTRACTOR_KeywordList* addKeyword | ( | EXTRACTOR_KeywordType | type, | |
| char * | keyword, | |||
| EXTRACTOR_KeywordList * | next | |||
| ) | [static] |
Definition at line 45 of file thumbnailextractor.c.
References EXTRACTOR_Keywords::keyword, EXTRACTOR_Keywords::keywordType, malloc, EXTRACTOR_Keywords::next, and NULL.
00047 { 00048 EXTRACTOR_KeywordList *result; 00049 00050 if (keyword == NULL) 00051 return next; 00052 result = malloc (sizeof (EXTRACTOR_KeywordList)); 00053 result->next = next; 00054 result->keyword = keyword; 00055 result->keywordType = type; 00056 return result; 00057 }
| struct EXTRACTOR_Keywords* libextractor_thumbnail_extract | ( | const char * | filename, | |
| const unsigned char * | data, | |||
| size_t | size, | |||
| struct EXTRACTOR_Keywords * | prev, | |||
| const char * | options | |||
| ) |
Definition at line 169 of file thumbnailextractor.c.
References libextractor_thumbnailgtk_extract().
00174 { 00175 return libextractor_thumbnailgtk_extract (filename, data, size, prev); 00176 }
| struct EXTRACTOR_Keywords* libextractor_thumbnailgtk_extract | ( | const char * | filename, | |
| const unsigned char * | data, | |||
| size_t | size, | |||
| struct EXTRACTOR_Keywords * | prev | |||
| ) |
Definition at line 81 of file thumbnailextractor.c.
References addKeyword(), EXTRACTOR_binaryEncode(), EXTRACTOR_extractLast(), EXTRACTOR_MIMETYPE, EXTRACTOR_SIZE, EXTRACTOR_THUMBNAIL_DATA, free, height, malloc, NULL, THUMBSIZE, and width.
Referenced by libextractor_thumbnail_extract().
00085 { 00086 GdkPixbufLoader *loader; 00087 GdkPixbuf *in; 00088 GdkPixbuf *out; 00089 size_t length; 00090 char *thumb; 00091 unsigned long width; 00092 unsigned long height; 00093 char *binary; 00094 const char *mime; 00095 int j; 00096 char *format; 00097 00098 /* if the mime-type of the file is not whitelisted 00099 do not run the thumbnail extactor! */ 00100 mime = EXTRACTOR_extractLast (EXTRACTOR_MIMETYPE, prev); 00101 if (mime == NULL) 00102 return prev; 00103 j = 0; 00104 while (whitelist[j] != NULL) 00105 { 00106 if (0 == strcmp (whitelist[j], mime)) 00107 break; 00108 j++; 00109 } 00110 if (whitelist[j] == NULL) 00111 return prev; 00112 00113 loader = gdk_pixbuf_loader_new (); 00114 gdk_pixbuf_loader_write (loader, data, size, NULL); 00115 in = gdk_pixbuf_loader_get_pixbuf (loader); 00116 gdk_pixbuf_loader_close (loader, NULL); 00117 if (in == NULL) 00118 { 00119 g_object_unref (loader); 00120 return prev; 00121 } 00122 g_object_ref (in); 00123 g_object_unref (loader); 00124 height = gdk_pixbuf_get_height (in); 00125 width = gdk_pixbuf_get_width (in); 00126 format = malloc (64); 00127 snprintf (format, 64, "%ux%u", (unsigned int) width, (unsigned int) height); 00128 prev = addKeyword (EXTRACTOR_SIZE, format, prev); 00129 if (height == 0) 00130 height = 1; 00131 if (width == 0) 00132 width = 1; 00133 if ((height <= THUMBSIZE) && (width <= THUMBSIZE)) 00134 { 00135 g_object_unref (in); 00136 return prev; 00137 } 00138 if (height > THUMBSIZE) 00139 { 00140 width = width * THUMBSIZE / height; 00141 height = THUMBSIZE; 00142 } 00143 if (width > THUMBSIZE) 00144 { 00145 height = height * THUMBSIZE / width; 00146 width = THUMBSIZE; 00147 } 00148 out = gdk_pixbuf_scale_simple (in, width, height, GDK_INTERP_BILINEAR); 00149 g_object_unref (in); 00150 thumb = NULL; 00151 if (!gdk_pixbuf_save_to_buffer (out, &thumb, &length, "png", NULL, 00152 "compression", 9, NULL)) 00153 { 00154 g_object_unref (out); 00155 return prev; 00156 } 00157 g_object_unref (out); 00158 if (thumb == NULL) 00159 return prev; 00160 00161 binary = EXTRACTOR_binaryEncode ((const unsigned char *) thumb, length); 00162 free (thumb); 00163 if (binary == NULL) 00164 return prev; 00165 return addKeyword (EXTRACTOR_THUMBNAIL_DATA, binary, prev); 00166 }
char* whitelist[] [static] |
Initial value:
{
"image/jpeg",
"image/gif",
"image/miff",
"image/mng",
"image/png",
"image/tiff",
"image/x-bmp",
"image/x-mng",
"image/x-png",
"image/x-xpm",
"image/xcf",
NULL,
}
Definition at line 65 of file thumbnailextractor.c.
1.5.1