Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
Windows Vista, Java 6 SE, incubator 0.97 and 0.98 SNAPSHOT
Description
JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
BufferedImage image = jpegMetadata.getEXIFThumbnail();
Above code seaches tiff directory structure but only searches for dir.getTiffImage() and only checks if tiffImageData is null. Jpeg files which have Jpeg thumbs stored as JpegImageData do not work.
I was able to fix this with following code:
import org.apache.sanselan.formats.tiff.JpegImageData; import javax.imageio.ImageIO; import java.io.ByteArrayInputStream; public BufferedImage getEXIFThumbnail() throws ImageReadException, IOException { ArrayList dirs = exif.getDirectories(); for (int i = 0; i < dirs.size(); i++) { TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs .get(i); // Debug.debug("dir", dir); BufferedImage image = dir.getThumbnail(); if (null != image) return image; JpegImageData jpegImageData = dir.getJpegImageData(); if(jpegImageData!=null){ ByteArrayInputStream input = new ByteArrayInputStream(jpegImageData.data); image = ImageIO.read(input); if (image!=null) return image; } } return null; }
Attachments
Attachments
Issue Links
- is depended upon by
-
IMAGING-48 JpegImageMetadata getEXIFThumbnail may raise a null pointer exception
- Closed