Using Java ImageIO to read embedded thumbnails in JPEG images

E

Enric Tordera

I'm trying to write some code to read the embedded thumbnails present in
JPEG images from digital cameras. I am using the ImageIO library

This is the code:

---------------------------------------------------
ImageInputStream iis = ImageIO.createImageInputStream(new
FileInputStream(filename));

Iterator readers = ImageIO.getImageReadersByFormatName("jpg");
ImageReader reader = null;
while (readers.hasNext()) {
reader = (ImageReader)readers.next();
if (reader.readerSupportsThumbnails()) {
reader.setInput(iis, true);
System.out.println("NumThumbnails:" + reader.getNumThumbnails(0));
}
}
----------------------------------------------



It always prints "0", so it seems the library can't find any Thumbnail
in the JPEG file, although I'm sure it is there.

Here are the questions:
* May be the embedded thumbnail is in the EXIF information, so ImageIO
does not support it?
* Is there another ImageReader available that fully supports reading
thumbnails?
* Any hint on how to do this?

Thanks in advance for your help.

- Enric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top