Author: damjan Date: Thu Oct 31 19:17:41 2013 New Revision: 1537588 URL: http://svn.apache.org/r1537588 Log: Fix a null Pointer exception bug for images missing an image height in the thumbnail.
Submitted by: Piyush Kapoor <pkapoor at adobe dot com> Jira issue key: IMAGING-121 Modified: commons/proper/imaging/trunk/src/changes/changes.xml commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java Modified: commons/proper/imaging/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/changes/changes.xml?rev=1537588&r1=1537587&r2=1537588&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/changes/changes.xml (original) +++ commons/proper/imaging/trunk/src/changes/changes.xml Thu Oct 31 19:17:41 2013 @@ -46,6 +46,9 @@ The <action> type attribute can be add,u <body> <release version="1.0" date="TBA" description="TBA"> + <action issue="IMAGING_121" dev="damjan" type="fix" due-to="Piyush Kapoor"> + Null Pointer exception while extracting metadata for CR2 image. + </action> <action issue="IMAGING-115" dev="damjan" type="fix"> DhtSegment class contains mutable public arrays. </action> Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1537588&r1=1537587&r2=1537588&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java Thu Oct 31 19:17:41 2013 @@ -459,7 +459,11 @@ public class TiffReader extends BinaryFi if (directory.imageDataInStrips()) { final TiffField rowsPerStripField = directory .findField(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP); - int rowsPerStrip; + /* + * Default value of rowsperstrip is assumed to be infinity + * http://www.awaresystems.be/imaging/tiff/tifftags/rowsperstrip.html + */ + int rowsPerStrip = Integer.MAX_VALUE; if (null != rowsPerStripField) { rowsPerStrip = rowsPerStripField.getIntValue(); @@ -470,7 +474,10 @@ public class TiffReader extends BinaryFi * if rows per strip not present then rowsPerStrip is equal to * imageLength or an infinity value; */ - rowsPerStrip = imageHeight.getIntValue(); + if (imageHeight != null) { + rowsPerStrip = imageHeight.getIntValue(); + } + } return new TiffImageData.Strips(data, rowsPerStrip);