[
https://issues.apache.org/jira/browse/SANSELAN-44?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sebb resolved SANSELAN-44.
--------------------------
Resolution: Fixed
> JpegImageMetadata getEXIFThumbnail may raise a null pointer exception
> ---------------------------------------------------------------------
>
> Key: SANSELAN-44
> URL: https://issues.apache.org/jira/browse/SANSELAN-44
> Project: Commons Sanselan
> Issue Type: Bug
> Affects Versions: 0.94-incubator
> Reporter: Alain
> Assignee: Sebb
>
> A patch has been done to read thumbnail from exif metada (see bug 38). But
> there is a bug if exif is null (NullpointerException):
> <code>
> 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;
> }
> </code>
> This patch correct the bug:
> <code>
> 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;
> </code>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.