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
extracting thumbnail from exif headers
Re: extracting thumbnail from exif headers
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
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).
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
Start with
- convert test.jpg thumbnail:thumb.jpg
Re: extracting thumbnail from exif headers
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?
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
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
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
I think ImageMagick might already be supporting retrieving these information. I see exif:ThumbnailData and exif:ThumbnailSize tags in property.c