Page 1 of 1
extracting thumbnail from exif headers
Posted: 2007-07-28T17:20:35-07:00
by eastern_strider
I was wondering if there is a function in Magick++ which returns the thumbnail image stored in an EXIF header (for JPEG and TIF files).
I'm developing a GUI application where I need to display thumbnails of multiple images rapidly. Reading the whole image and scaling down to create thumbnails works too slow for my purposes.
Thanks,
eastern_strider
Re: extracting thumbnail from exif headers
Posted: 2007-07-28T18:47:27-07:00
by magick
Write to a blob in the thumbnail: image format. As you may have guessed, the thumbnail: image format is the thumbnail extracted from the EXIF profile.
Re: extracting thumbnail from exif headers
Posted: 2007-07-28T19:42:25-07:00
by eastern_strider
Do you mean something like that?
Image image("test.jpg");
Blob blob;
image.write(&blob, "thumbnail:JPEG");
Image image2(blob);
image2.write("thumb.jpg");
But in this case the output image becomes the same size as input image.
I also tried image.write(&blob, "thumbnail: JPEG") . This gives "zero-length blob not permitted" exception.
What am I doing wrong? (I'm certain that the image has thumbnail in the exif header).
Re: extracting thumbnail from exif headers
Posted: 2007-07-28T20:54:55-07:00
by magick
Start with
- convert test.jpg thumbnail:thumb.jpg
Does that produce a thumbnail image? It does for us. If not try upgrading your version of ImageMagick. If it still fails, post a URL to your image here so we can download and determine why the thumbnail is not being read.
Re: extracting thumbnail from exif headers
Posted: 2007-07-28T21:12:52-07:00
by eastern_strider
convert test.jpg thumbnail:thumb.jpg does produce thumbnail. The magick++ API does not. I'm probably not using the magick++ functions properly. But I've uploaded the file at
http://www.coolhall.com/homepage/files/test.jpg in case you'd like also like to try.
One issue though. Even if this works, it seems that the entire image is read when we create the image. The call:
Image image("test.jpg");
reads and decodes the whole JPEG file isn't it? Wouldn't it be much slower than just reading the thumbnail?
Re: extracting thumbnail from exif headers
Posted: 2007-07-28T21:43:33-07:00
by magick
If all your images are JPEG you can set the image_info->size attribute to something like 160x160 and ImageMagick will only create a small image internally. However, the most efficient implementation would extract the EXIF profile directly and extract the thumbnail, however ImageMagick does not directly provide an interface to just extract the EXIF profile without reading the image pixels.
Re: extracting thumbnail from exif headers
Posted: 2007-07-28T21:48:13-07:00
by eastern_strider
Okay, thanks for the clarification.
Re: extracting thumbnail from exif headers
Posted: 2007-07-28T22:11:22-07:00
by eastern_strider
Thanks to Blob class efficient retrieval of thumbnail from Exif shouldn't be difficult in any case. It boils down to locating the position and size of the thumbnail, reading it as a binary chunk from the disk and passing the result to a blob.
I think ImageMagick might already be supporting retrieving these information. I see exif:ThumbnailData and exif:ThumbnailSize tags in property.c