TIFF RowsPerStrip can be absent, and means infinity.
Submittted by: Piyush Kapoor <pkapoor at adobe dot com>
Jira issue key: SANSELAN-65
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/sanselan/trunk@1297330 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java b/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
index ee18745..d73b162 100644
--- a/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
+++ b/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
@@ -478,9 +478,18 @@
{
TiffField rowsPerStripField = directory
.findField(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP);
- if (null == rowsPerStripField)
- throw new ImageReadException("Can't find rows per strip field.");
- int rowsPerStrip = rowsPerStripField.getIntValue();
+ int rowsPerStrip ;
+
+ if (null != rowsPerStripField) {
+ rowsPerStrip = rowsPerStripField.getIntValue();
+ } else {
+ TiffField imageHeight = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH);
+ /**
+ * if rows per strip not present then rowsPerStrip
+ * is equal to imageLength or an infinity value;
+ */
+ rowsPerStrip = imageHeight.getIntValue();
+ }
return new TiffImageData.Strips(data, rowsPerStrip);
} else