commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alain (JIRA)" <j...@apache.org>
Subject [jira] Updated: (SANSELAN-44) JpegImageMetadata getEXIFThumbnail may raise a null pointer exception
Date Tue, 21 Sep 2010 14:11:35 GMT

     [ https://issues.apache.org/jira/browse/SANSELAN-44?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alain updated SANSELAN-44:
--------------------------

    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):

<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>

  was:
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 = exifs.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>


> 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
>
> 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.


Mime
View raw message