Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.97
-
None
-
None
Description
A patch has been done to read thumbnail from exif metada (see bug 38). But there is a bug if exif is null (NullpointerException):
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; }
This patch correct the bug:
if (exif!= null) { 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
Issue Links
- depends upon
-
IMAGING-18 JpegImageMetadata getEXIFThumbnail only works on Jpeg thumbnails stored as Tiff images.
- Closed