commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1331283 - /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java
Date Fri, 27 Apr 2012 07:59:12 GMT
Author: damjan
Date: Fri Apr 27 07:59:10 2012
New Revision: 1331283

URL: http://svn.apache.org/viewvc?rev=1331283&view=rev
Log:
Make all JpegImageMetadata methods handle a null exif field.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java?rev=1331283&r1=1331282&r2=1331283&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java
Fri Apr 27 07:59:10 2012
@@ -67,7 +67,11 @@ public class JpegImageMetadata implement
 
     public TiffField findEXIFValueWithExactMatch(TagInfo tagInfo) {
         try {
-            return exif.findField(tagInfo, true);
+            if (exif != null) {
+                return exif.findField(tagInfo, true);
+            } else {
+                return null;
+            }
         } catch (ImageReadException cannotHappen) {
             return null;
         }
@@ -97,6 +101,9 @@ public class JpegImageMetadata implement
      * @throws IOException
      */
     public byte[] getEXIFThumbnailData() throws ImageReadException, IOException {
+        if (exif == null) {
+            return null;
+        }
         List<? extends IImageMetadataItem> dirs = exif.getDirectories();
         for (int i = 0; i < dirs.size(); i++) {
             TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs
@@ -155,6 +162,9 @@ public class JpegImageMetadata implement
     }
 
     public TiffImageData getRawImageData() {
+        if (exif == null) {
+            return null;
+        }
         List<? extends IImageMetadataItem> dirs = exif.getDirectories();
         for (int i = 0; i < dirs.size(); i++) {
             TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs



Mime
View raw message