You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/02/22 19:14:08 UTC

(commons-imaging) branch master updated (c77514b5 -> ca168e56)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git


    from c77514b5 Add ImageFormats
     new 1a275ea9 Use ternary expression
     new 1234dfd7 Use ArrayUtils
     new d8954c40 Use forEach()
     new bbea07e0 Inline single use local variable
     new ca168e56 Use forEach()

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/imaging/formats/jpeg/JpegImageParser.java       | 13 ++-----------
 .../apache/commons/imaging/formats/psd/PsdImageParser.java  | 13 ++-----------
 .../apache/commons/imaging/formats/tiff/TiffDirectory.java  |  4 +---
 .../commons/imaging/formats/tiff/TiffImageParser.java       |  7 ++-----
 .../commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java   |  6 +-----
 5 files changed, 8 insertions(+), 35 deletions(-)


(commons-imaging) 05/05: Use forEach()

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit ca168e566678eadaaedf42eb1e88c2ffdaf7961a
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 22 10:59:37 2025 -0500

    Use forEach()
---
 .../java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
index 7ffe8151..addac647 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
@@ -617,9 +617,7 @@ public class TiffImageParser extends AbstractImageParser<TiffImagingParameters>
 
             final List<TiffField> entries = dir.getDirectoryEntries();
 
-            for (final TiffField entry : entries) {
-                metadataDirectory.add(entry);
-            }
+            entries.forEach(metadataDirectory::add);
 
             result.add(metadataDirectory);
         }


(commons-imaging) 01/05: Use ternary expression

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit 1a275ea9d57ca8a8433bddd89567dec31dac4222
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 22 10:52:51 2025 -0500

    Use ternary expression
---
 .../apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java    | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java
index d5003295..c010e144 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4_T6_Tables.java
@@ -28,11 +28,7 @@ final class T4_T6_Tables {
 
         public void writeBits(final BitArrayOutputStream outputStream) {
             for (int i = 0; i < bitString.length(); i++) {
-                if (bitString.charAt(i) == '0') {
-                    outputStream.writeBit(0);
-                } else {
-                    outputStream.writeBit(1);
-                }
+                outputStream.writeBit(bitString.charAt(i) == '0' ? 0 : 1);
             }
         }
     }


(commons-imaging) 02/05: Use ArrayUtils

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit 1234dfd7ea46000b1ea0a0d324710f9c917be5b6
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 22 10:53:16 2025 -0500

    Use ArrayUtils
---
 .../commons/imaging/formats/jpeg/JpegImageParser.java       | 13 ++-----------
 .../apache/commons/imaging/formats/psd/PsdImageParser.java  | 13 ++-----------
 2 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
index cafbd5f1..9ca17038 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
@@ -61,6 +61,7 @@ import org.apache.commons.imaging.formats.tiff.TiffImageParser;
 import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.imaging.internal.Debug;
+import org.apache.commons.lang3.ArrayUtils;
 
 public class JpegImageParser extends AbstractImageParser<JpegImagingParameters> implements XmpEmbeddable<JpegImagingParameters> {
 
@@ -852,17 +853,7 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
     }
 
     private boolean keepMarker(final int marker, final int[] markers) {
-        if (markers == null) {
-            return true;
-        }
-
-        for (final int marker2 : markers) {
-            if (marker2 == marker) {
-                return true;
-            }
-        }
-
-        return false;
+        return ArrayUtils.contains(markers, marker);
     }
 
     public List<AbstractSegment> readSegments(final ByteSource byteSource, final int[] markers, final boolean returnAfterFirst)
diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java b/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
index 2e4b3dc5..854a9986 100644
--- a/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
@@ -46,6 +46,7 @@ import org.apache.commons.imaging.formats.psd.dataparsers.DataParserRgb;
 import org.apache.commons.imaging.formats.psd.datareaders.CompressedDataReader;
 import org.apache.commons.imaging.formats.psd.datareaders.DataReader;
 import org.apache.commons.imaging.formats.psd.datareaders.UncompressedDataReader;
+import org.apache.commons.lang3.ArrayUtils;
 
 public class PsdImageParser extends AbstractImageParser<PsdImagingParameters> implements XmpEmbeddable {
 
@@ -490,17 +491,7 @@ public class PsdImageParser extends AbstractImageParser<PsdImagingParameters> im
     }
 
     private boolean keepImageResourceBlock(final int id, final int[] imageResourceIDs) {
-        if (imageResourceIDs == null) {
-            return true;
-        }
-
-        for (final int imageResourceID : imageResourceIDs) {
-            if (id == imageResourceID) {
-                return true;
-            }
-        }
-
-        return false;
+        return ArrayUtils.contains(imageResourceIDs, id);
     }
 
     private PsdHeaderInfo readHeader(final ByteSource byteSource) throws ImagingException, IOException {


(commons-imaging) 04/05: Inline single use local variable

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit bbea07e09df59f5c47821e2d29eaf4a6afa65e05
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 22 10:55:05 2025 -0500

    Inline single use local variable
---
 .../java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
index 81bfb568..7ffe8151 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
@@ -465,8 +465,7 @@ public class TiffImageParser extends AbstractImageParser<TiffImagingParameters>
 
         final List<String> comments = Allocator.arrayList(directory.size());
         for (final TiffField field : directory) {
-            final String comment = field.toString();
-            comments.add(comment);
+            comments.add(field.toString());
         }
 
         final ImageFormat format = ImageFormats.TIFF;


(commons-imaging) 03/05: Use forEach()

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit d8954c40c23d23e131d6e665acfd4cb48d245f0b
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Feb 22 10:54:49 2025 -0500

    Use forEach()
---
 .../java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java   | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
index cd9f5595..a47ebea4 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
@@ -127,9 +127,7 @@ public class TiffDirectory extends AbstractTiffElement implements Iterable<TiffF
     }
 
     public void dump() {
-        for (final TiffField entry : entries) {
-            entry.dump();
-        }
+        entries.forEach(TiffField::dump);
     }
 
     public TiffField findField(final TagInfo tag) throws ImagingException {