garydgregory commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1330151666


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##########
@@ -455,27 +473,55 @@ private TiffHeader readTiffHeader(final ByteSource 
byteSource) throws ImagingExc
         }
     }
 
-    private TiffHeader readTiffHeader(final InputStream is) throws 
ImagingException, IOException {
-        final int byteOrder1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF 
File");
-        final int byteOrder2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF 
File");
-        if (byteOrder1 != byteOrder2) {
-            throw new ImagingException("Byte Order bytes don't match (" + 
byteOrder1 + ", " + byteOrder2 + ").");
-        }
-
-        final ByteOrder byteOrder = getTiffByteOrder(byteOrder1);
-        setByteOrder(byteOrder);
-
-        final int tiffVersion = read2Bytes("tiffVersion", is, "Not a Valid 
TIFF File", getByteOrder());
-        if (tiffVersion != 42) {
-            throw new ImagingException("Unknown TIFF Version: " + tiffVersion);
-        }
+   private TiffHeader readTiffHeader(final InputStream is) throws 
ImagingException, IOException {
+    final int byteOrder1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF 
File");
+    final int byteOrder2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF 
File");
+    if (byteOrder1 != byteOrder2) {
+      throw new ImagingException("Byte Order bytes don't match (" + byteOrder1 
+ ", " + byteOrder2 + ").");
+    }
 
-        final long offsetToFirstIFD =
-                0xFFFFffffL & read4Bytes("offsetToFirstIFD", is, "Not a Valid 
TIFF File", getByteOrder());
+    final ByteOrder byteOrder = getTiffByteOrder(byteOrder1);
+    setByteOrder(byteOrder);
+
+    // verify that the file is a supported TIFF format using
+    // the numeric indentifier
+    //     Classic TIFF (32 bit):    42
+    //     Big TIFF (64 bit):        43
+    //
+    final long offsetToFirstIFD;
+    final int tiffVersion = read2Bytes("tiffVersion", is, "Not a Valid TIFF 
File", getByteOrder());
+    if (tiffVersion == TIFF_VERSION_STANDARD) {
+      bigTiff = false;
+      standardTiff = true;
+      entryMaxValueLength = TIFF_ENTRY_MAX_VALUE_LENGTH;
+      offsetToFirstIFD
+        = 0xFFFFffffL & read4Bytes(
+          "offsetToFirstIFD", is, "Not a Valid TIFF File", getByteOrder());
+    } else if (tiffVersion == TIFF_VERSION_BIG) {
+      bigTiff = true;
+      standardTiff = false;
+       entryMaxValueLength = TIFF_ENTRY_MAX_VALUE_LENGTH_BIG;
+      int byteSize

Review Comment:
   I'm really not a fan of "newspaper" formatting, IOW very short lines. I've 
set the checkstyle max line length to 160 (you can rebase if you want to pick 
that up).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to