You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "gwlucastrig (via GitHub)" <gi...@apache.org> on 2023/09/12 23:38:01 UTC

[GitHub] [commons-imaging] gwlucastrig opened a new pull request, #318: Imaging-316: Add support for BigTIFF format

gwlucastrig opened a new pull request, #318:
URL: https://github.com/apache/commons-imaging/pull/318

   These changes add support for the BigTIFF format. They enable the Commons Imaging library to read TIFF files of size larger than supported by a 32-bit address space.  A dedicated test case and a set of BigTIFF sample files are included.
   
   Please see the Commons Imaging JIRA tracker issue 316 at  [https://issues.apache.org/jira/browse/IMAGING-316](https://issues.apache.org/jira/browse/IMAGING-316) for more detail.
   
   The ability to write BigTIFF files will be reserved for a future pull request


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on a diff in pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1330201121


##########
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 agree completely on newspaper formatting.  I will rebase and address code changes



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] garydgregory commented on a diff in pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#issuecomment-1738274426

   Added Javadoc and corrected formatting.  In order to support an additional JUnit test, I needed to add a new toBytes() method for longs.  This method wasn't required for reading BigTIFFs, but it was necessary to implement the JUnit test.  It will be useful in the future for any implementation that writes BigTIFFs (the current implementation only reads them).
    


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#issuecomment-1725688908

   Will address these comments and update code.


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] garydgregory commented on a diff in pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1338737448


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -234,6 +234,14 @@ public int[] getIntArrayValue() throws ImagingException {
             final int[] numbers = (int[]) o;
             return Arrays.copyOf(numbers, numbers.length);
         }
+        if (o instanceof long[]){

Review Comment:
   The formatting seems off in the block, missing spaces.



##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -288,6 +296,55 @@ public int getIntValueOrArraySum() throws ImagingException {
         // return -1;
     }
 
+    public long[] getLongArrayValue() throws ImagingException {

Review Comment:
   We should provide Javadocs on all new public and protected methods IMO.



##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##########
@@ -455,27 +473,47 @@ 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 {

Review Comment:
   Formatting seems odd.



##########
src/main/java/org/apache/commons/imaging/common/ByteConversions.java:
##########
@@ -399,6 +399,43 @@ private static int[] toUInt16s(final byte[] bytes, final int offset, final int l
         return result;
     }
 
+     public static long toLong(final byte[] bytes, final ByteOrder byteOrder) {

Review Comment:
   Also, it looks like there is an extra space in front of `public`?



##########
src/main/java/org/apache/commons/imaging/common/ByteConversions.java:
##########
@@ -399,6 +399,43 @@ private static int[] toUInt16s(final byte[] bytes, final int offset, final int l
         return result;
     }
 
+     public static long toLong(final byte[] bytes, final ByteOrder byteOrder) {

Review Comment:
   We should provide Javadocs on all new public and protected methods IMO.



##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -288,6 +296,55 @@ public int getIntValueOrArraySum() throws ImagingException {
         // return -1;
     }
 
+    public long[] getLongArrayValue() throws ImagingException {
+        final Object o = getValue();
+        // if (o == null)
+        // return null;
+
+        if (o instanceof Number) {
+            return new  long[] { ((Number) o).longValue() };
+        }
+        if (o instanceof Number[]) {
+            final Number[] numbers = (Number[]) o;
+            final long[] result = Allocator.longArray(numbers.length);
+            Arrays.setAll(result, i -> numbers[i].longValue());
+            return result;
+        }
+        if (o instanceof short[]) {
+            final short[] numbers = (short[]) o;
+            final long[] result = Allocator.longArray(numbers.length);
+            Arrays.setAll(result, i ->  0xffff & numbers[i]);
+            return result;
+        }
+        if (o instanceof int[]) {
+            final int[] numbers = (int[]) o;
+            final long[]result = Allocator.longArray(numbers.length);
+            Arrays.setAll(result, i ->  0xFFFFffffL & numbers[i]);
+            return result;
+        }
+        if (o instanceof long[]){
+          final long[] numbers = (long[]) o;
+          return Arrays.copyOf(numbers, numbers.length);
+        }
+
+        throw new ImagingException("Unknown value: " + o + " for: "
+                + getTagInfo().getDescription());
+        // return null;
+    }
+
+    public long getLongValue() throws ImagingException {

Review Comment:
   We should provide Javadocs on all new public and protected methods IMO.



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] garydgregory commented on a diff in pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341381002


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##########
@@ -16,27 +16,29 @@
  */
 package org.apache.commons.imaging.formats.tiff;
 
-import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.read4Bytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.readByte;
-import static org.apache.commons.imaging.common.BinaryFunctions.readBytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.skipBytes;
-import static org.apache.commons.imaging.formats.tiff.constants.TiffConstants.TIFF_ENTRY_MAX_VALUE_LENGTH;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteOrder;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.apache.commons.imaging.FormatCompliance;
 import org.apache.commons.imaging.ImagingException;
 import org.apache.commons.imaging.bytesource.ByteSource;
 import org.apache.commons.imaging.common.BinaryFileParser;
+import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes;

Review Comment:
   All statics should be grouped at the top. Not sure if Checkstyle can check for us though.



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on a diff in pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341955791


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##########
@@ -16,27 +16,29 @@
  */
 package org.apache.commons.imaging.formats.tiff;
 
-import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.read4Bytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.readByte;
-import static org.apache.commons.imaging.common.BinaryFunctions.readBytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.skipBytes;
-import static org.apache.commons.imaging.formats.tiff.constants.TiffConstants.TIFF_ENTRY_MAX_VALUE_LENGTH;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteOrder;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.apache.commons.imaging.FormatCompliance;
 import org.apache.commons.imaging.ImagingException;
 import org.apache.commons.imaging.bytesource.ByteSource;
 import org.apache.commons.imaging.common.BinaryFileParser;
+import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes;

Review Comment:
   done



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] garydgregory commented on a diff in pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1330152071


##########
src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java:
##########
@@ -177,6 +177,44 @@ public static int read4Bytes(final String name, final InputStream is,
         return result;
     }
 
+   public static long read8Bytes(final String name,

Review Comment:
   Javadoc?



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#issuecomment-1725312015

   Do you have a feel for when this PR might get merged or, failing that, rejected?  I've got some other stuff I'm working on and am trying to plan for the next few weeks.


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on a diff in pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341290534


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -288,6 +296,55 @@ public int getIntValueOrArraySum() throws ImagingException {
         // return -1;
     }
 
+    public long[] getLongArrayValue() throws ImagingException {

Review Comment:
   done



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] garydgregory merged pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #318:
URL: https://github.com/apache/commons-imaging/pull/318


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on a diff in pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341293220


##########
src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java:
##########
@@ -177,6 +177,44 @@ public static int read4Bytes(final String name, final InputStream is,
         return result;
     }
 
+   public static long read8Bytes(final String name,

Review Comment:
   done



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#issuecomment-1734616510

   I hope I did this right.  Please let me know if it didn't work. 
   
   I am not adept at Git and was unable to find a clear set of instructions for submitting changes in response to a PR review. I'm sure they're out there, but I didn't find them.


-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] codecov-commenter commented on pull request #318: Imaging-316: Add support for BigTIFF format

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#issuecomment-1716769298

   ## [Codecov](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#318](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (e1929d0) into [master](https://app.codecov.io/gh/apache/commons-imaging/commit/5b6f6f519dc22b979177196768367070894051cb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (5b6f6f5) will **increase** coverage by `0.05%`.
   > The diff coverage is `70.22%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #318      +/-   ##
   ============================================
   + Coverage     70.82%   70.87%   +0.05%     
   - Complexity     3405     3429      +24     
   ============================================
     Files           333      334       +1     
     Lines         16834    16947     +113     
     Branches       2588     2607      +19     
   ============================================
   + Hits          11922    12011      +89     
   - Misses         3897     3916      +19     
   - Partials       1015     1020       +5     
   ```
   
   
   | [Files Changed](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [.../imaging/formats/tiff/constants/TiffConstants.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3RpZmYvY29uc3RhbnRzL1RpZmZDb25zdGFudHMuamF2YQ==) | `100.00% <ø> (ø)` | |
   | [...maging/formats/tiff/fieldtypes/FieldTypeLong8.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3RpZmYvZmllbGR0eXBlcy9GaWVsZFR5cGVMb25nOC5qYXZh) | `36.84% <36.84%> (ø)` | |
   | [...apache/commons/imaging/formats/tiff/TiffField.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3RpZmYvVGlmZkZpZWxkLmphdmE=) | `50.00% <44.11%> (+3.14%)` | :arrow_up: |
   | [...apache/commons/imaging/common/BinaryFunctions.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9jb21tb24vQmluYXJ5RnVuY3Rpb25zLmphdmE=) | `61.19% <85.71%> (+2.86%)` | :arrow_up: |
   | [...pache/commons/imaging/formats/tiff/TiffReader.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3RpZmYvVGlmZlJlYWRlci5qYXZh) | `79.02% <86.04%> (+1.92%)` | :arrow_up: |
   | [...apache/commons/imaging/common/ByteConversions.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9jb21tb24vQnl0ZUNvbnZlcnNpb25zLmphdmE=) | `94.97% <100.00%> (+0.43%)` | :arrow_up: |
   | [...he/commons/imaging/formats/tiff/TiffDirectory.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3RpZmYvVGlmZkRpcmVjdG9yeS5qYXZh) | `30.34% <100.00%> (ø)` | |
   | [...pache/commons/imaging/formats/tiff/TiffHeader.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3RpZmYvVGlmZkhlYWRlci5qYXZh) | `85.71% <100.00%> (+2.38%)` | :arrow_up: |
   | [...ing/formats/tiff/fieldtypes/AbstractFieldType.java](https://app.codecov.io/gh/apache/commons-imaging/pull/318?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3RpZmYvZmllbGR0eXBlcy9BYnN0cmFjdEZpZWxkVHlwZS5qYXZh) | `100.00% <100.00%> (ø)` | |
   
   ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/apache/commons-imaging/pull/318/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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: notifications-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on a diff in pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341389642


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##########
@@ -16,27 +16,29 @@
  */
 package org.apache.commons.imaging.formats.tiff;
 
-import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.read4Bytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.readByte;
-import static org.apache.commons.imaging.common.BinaryFunctions.readBytes;
-import static org.apache.commons.imaging.common.BinaryFunctions.skipBytes;
-import static org.apache.commons.imaging.formats.tiff.constants.TiffConstants.TIFF_ENTRY_MAX_VALUE_LENGTH;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteOrder;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.apache.commons.imaging.FormatCompliance;
 import org.apache.commons.imaging.ImagingException;
 import org.apache.commons.imaging.bytesource.ByteSource;
 import org.apache.commons.imaging.common.BinaryFileParser;
+import static org.apache.commons.imaging.common.BinaryFunctions.read2Bytes;

Review Comment:
   I ran checkstyle before submitting and it didn't complain.  But I definitely agree that the statics should go first. I will modify this and submit a new commit tonight or tomorrow.



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on a diff in pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341290307


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##########
@@ -455,27 +473,47 @@ 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 {

Review Comment:
   done



##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -288,6 +296,55 @@ public int getIntValueOrArraySum() throws ImagingException {
         // return -1;
     }
 
+    public long[] getLongArrayValue() throws ImagingException {
+        final Object o = getValue();
+        // if (o == null)
+        // return null;
+
+        if (o instanceof Number) {
+            return new  long[] { ((Number) o).longValue() };
+        }
+        if (o instanceof Number[]) {
+            final Number[] numbers = (Number[]) o;
+            final long[] result = Allocator.longArray(numbers.length);
+            Arrays.setAll(result, i -> numbers[i].longValue());
+            return result;
+        }
+        if (o instanceof short[]) {
+            final short[] numbers = (short[]) o;
+            final long[] result = Allocator.longArray(numbers.length);
+            Arrays.setAll(result, i ->  0xffff & numbers[i]);
+            return result;
+        }
+        if (o instanceof int[]) {
+            final int[] numbers = (int[]) o;
+            final long[]result = Allocator.longArray(numbers.length);
+            Arrays.setAll(result, i ->  0xFFFFffffL & numbers[i]);
+            return result;
+        }
+        if (o instanceof long[]){
+          final long[] numbers = (long[]) o;
+          return Arrays.copyOf(numbers, numbers.length);
+        }
+
+        throw new ImagingException("Unknown value: " + o + " for: "
+                + getTagInfo().getDescription());
+        // return null;
+    }
+
+    public long getLongValue() throws ImagingException {

Review Comment:
   done



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-imaging] gwlucastrig commented on a diff in pull request #318: [IMAGING-316] Add support for BigTIFF format

Posted by "gwlucastrig (via GitHub)" <gi...@apache.org>.
gwlucastrig commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1341289953


##########
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##########
@@ -234,6 +234,14 @@ public int[] getIntArrayValue() throws ImagingException {
             final int[] numbers = (int[]) o;
             return Arrays.copyOf(numbers, numbers.length);
         }
+        if (o instanceof long[]){

Review Comment:
   done



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org