-
Notifications
You must be signed in to change notification settings - Fork 488
Description
Hi,
I'm using ImageMetadataReader to read metadata from a jpeg file, and I'd like to gain access to the thumbnail bytes.
Previously, using version 2.7, I could do this:
ExifThumbnailDirectory thumbDir = metadata.getDirectory(ExifThumbnailDirectory.class);
if (thumbDir.hasThumbnailData())
{
byte[] tdata = thumbDir.getThumbnailData();
and could then have access to the bytes of the thumbnail image.
With version 2.10, these methods are no longer available, so I try this:
ExifThumbnailDirectory thumbDir = metadata.getFirstDirectoryOfType(ExifThumbnailDirectory.class);
if (thumbDir.containsTag(ExifThumbnailDirectory.TAG_COMPRESSION))
{
Integer offset = thumbDir.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_OFFSET);
Integer length = thumbDir.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_LENGTH);
so I can get the offset (relative to the start of this directory?) and the length of the data block, but I cannot see how to get access to the data itself.
I have tried reading the jpeg file afterwards (using a FileInputStream) and extracting bytes from it, but that only works if I add the value (from TAG_THUMBNAIL_OFFSET) to a further offset to go from the start of the file, and the appropriate value to add depends on which jpeg I'm using. So I guess I need to ask the thumbDir what its offset is relative to the start of the file, and add that to the value of the TAG_THUMBNAIL_OFFSET, is that correct? Does the Directory class have any way to know where it is? Or can the Metadata object tell where a directory (or its data) can be found?
Or am I missing something and the thumbnail bytes are accessible in another way?