From bce6da53eaf4617e7b1e60fc4a702f11326e11f3 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 3 Jun 2009 20:41:08 +0000 Subject: [PATCH] * Be more picky about what we call thumbnails for JPEG images. Verify that the resolution is <= 160x160 to comply with the DLNA spec. --- metadata.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/metadata.c b/metadata.c index 64cfaa4..d6d81d5 100644 --- a/metadata.c +++ b/metadata.c @@ -27,6 +27,7 @@ #include #include +#include "image_utils.h" #include #include #include @@ -345,6 +346,7 @@ GetImageMetadata(const char * path, char * name) struct stat file; sqlite_int64 ret; char *sql; + image * imsrc; metadata_t m; memset(&m, '\0', sizeof(metadata_t)); @@ -410,9 +412,25 @@ GetImageMetadata(const char * path, char * name) //DEBUG DPRINTF(E_DEBUG, L_METADATA, " * model: %s\n", model); if( ed->size ) - thumb = 1; - else - thumb = 0; + { + /* We might need to verify that the thumbnail is 160x160 or smaller */ + if( ed->size > 12000 ) + { + imsrc = image_new_from_jpeg(NULL, 0, (char *)ed->data, ed->size); + if( imsrc ) + { + if( (imsrc->width <= 160) && (imsrc->height <= 160) ) + { + thumb = 1; + } + image_free(imsrc); + } + } + else + { + thumb = 1; + } + } //DEBUG DPRINTF(E_DEBUG, L_METADATA, " * thumbnail: %d\n", thumb); exif_data_unref(ed);