You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2023/01/13 02:02:19 UTC

[GitHub] [commons-imaging] Glavo opened a new pull request, #269: [WIP] Support PNG extension

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

   I hope to support [Extensions to the PNG 1.2 Specification, Version 1.5.0](http://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html) in this PR and be ready to support APNG in subsequent PR.
   
   Some completed work:
   
   * Add an enum representing the PNG extension type;
   * Refactoring `PngImageParser::readChunks` and `ChunkType` to improve maintainability makes it easier to add new Chunk types later;
   * Support reading EXIF from PNG images.
   
   Things still need to be done:
   
   * Merge EXIF into PNG metadata;
   * Think about where extensions chunk types should be placed.
   


-- 
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


Re: [PR] [IMAGING-340] Support PNG extension [commons-imaging]

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

   I understand the frustration @StefanOltmann , and I am sure there are ways to improve how we interact here (on both ends, including myself). I have not followed everything that's happening due to these $work projects/deadlines, but I will try to catch up with everything that is happening and slowly start to review issues and pull requests, and also fix the security warnings we have.
   
   Feel free to ping me in issues/pull requests if you'd like, just expect some delays until the end of this month :+1: And as for your interaction with Gary/others, please consider that they are trying to help as I was the last person more actively working, but I have been away for some months now (apologies, again). They are trying to help as much as they can, and there can be some misunderstanding, but finding a way to work well and communicate your frustrations clearly and politely is key -- not only for ASF, but for your own personal open source projects :+1: 


-- 
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


Re: [PR] [IMAGING-340] Support PNG extension [commons-imaging]

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

   @kinow 
   
   Thank you for reaching out and providing an update.
   
   I must admit, I've encountered some frustration recently. Over the past few months, the only noticeable activity on the project seems to be from Gary, who has been addressing minor style issues but not significantly contributing otherwise. It appears he hasn't been thoroughly reviewing code in pull requests and may not grasp the project's domain.
   
   Even without unit tests, confirming the correctness of the bugfix in my pull request or validating the provided test should have been straightforward for someone familiar with the codebase and its intricacies. This is the kind of scrutiny and understanding that someone actively engaged in the project could provide.
   
   I recall observing this level of engagement from you some time ago, which is why I directed my concerns to you.
   
   Maybe the project isn’t dead, given the abundance of open issues and pull requests coupled with the lack of substantial development, it's difficult to characterize it as an actively progressing endeavor.
   
   I am glad to hear that you plan to pick up the work here, because this project deserves real maintenance.
   
   How Gary acts on my PRs is just ridiculous. First he wanted me to include a test image and provide a test - both would not have been necessary. After I did go the extra mile he doesn’t want the test (because he does not seem to understand what it does) and now all of the sudden the inclusion of the test image is a problem. That’s really sad and ridiculous maintenance. I believe this projects deserves better.


-- 
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] Glavo commented on pull request #269: [IMAGING-340] Support PNG extension

Posted by GitBox <gi...@apache.org>.
Glavo commented on PR #269:
URL: https://github.com/apache/commons-imaging/pull/269#issuecomment-1383022457

   I updated this PR, followed the requirements of IMAGING-341, and recorded the standard version in the document.
   
   Can someone review this PR?


-- 
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 #269: [WIP] Support PNG extension

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #269:
URL: https://github.com/apache/commons-imaging/pull/269#issuecomment-1381344937

   # [Codecov](https://codecov.io/gh/apache/commons-imaging/pull/269?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#269](https://codecov.io/gh/apache/commons-imaging/pull/269?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b1aa9fe) into [master](https://codecov.io/gh/apache/commons-imaging/commit/b103b1a4b5075885d3b34b8a93349f2839d76303?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b103b1a) will **decrease** coverage by `0.05%`.
   > The diff coverage is `74.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master     #269      +/-   ##
   ============================================
   - Coverage     70.73%   70.68%   -0.06%     
   + Complexity     3362     3360       -2     
   ============================================
     Files           332      333       +1     
     Lines         16936    16951      +15     
     Branches       2652     2647       -5     
   ============================================
   + Hits          11980    11982       +2     
   - Misses         3907     3918      +11     
   - Partials       1049     1051       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/commons-imaging/pull/269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/commons/imaging/formats/png/PngImageParser.java](https://codecov.io/gh/apache/commons-imaging/pull/269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3BuZy9QbmdJbWFnZVBhcnNlci5qYXZh) | `58.41% <9.09%> (-4.36%)` | :arrow_down: |
   | [.../apache/commons/imaging/formats/png/ChunkType.java](https://codecov.io/gh/apache/commons-imaging/pull/269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3BuZy9DaHVua1R5cGUuamF2YQ==) | `93.61% <91.66%> (-6.39%)` | :arrow_down: |
   | [.../apache/commons/imaging/formats/png/Extension.java](https://codecov.io/gh/apache/commons-imaging/pull/269?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL3BuZy9FeHRlbnNpb24uamF2YQ==) | `100.00% <100.00%> (ø)` | |
   
   :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=The+Apache+Software+Foundation)
   


-- 
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


Re: [PR] [IMAGING-340] Support PNG extension [commons-imaging]

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

   This component is definitely not dead.


-- 
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] kinow commented on a diff in pull request #269: [IMAGING-340] Support PNG extension

Posted by GitBox <gi...@apache.org>.
kinow commented on code in PR #269:
URL: https://github.com/apache/commons-imaging/pull/269#discussion_r1070592972


##########
src/main/java/org/apache/commons/imaging/formats/png/package-info.java:
##########
@@ -16,7 +16,14 @@
  */
 
 /**
- * The PNG image format.
+ * The PNG (Portable Network Graphics) image format.
+ * <p>
+ * The implementation is based on the
+ * <a href="http://www.libpng.org/pub/png/spec/1.2/">PNG specification version 1.2</a>,
+ * and supports the following extensions:
+ * <ul>
+ *     <li><a href="http://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html">Extensions to the PNG 1.2 Specification, Version 1.5.0</a></li>
+ * </ul>

Review Comment:
   Thank you! :clap: 



##########
src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java:
##########
@@ -282,21 +263,53 @@ public Dimension getImageSize(final ByteSource byteSource, final PngImagingParam
     @Override
     public ImageMetadata getMetadata(final ByteSource byteSource, final PngImagingParameters params)
             throws ImageReadException, IOException {
-        final List<PngChunk> chunks = readChunks(byteSource, new ChunkType[] { ChunkType.tEXt, ChunkType.zTXt, ChunkType.iTXt }, false);
+        final ChunkType[] chunkTypes = { ChunkType.tEXt, ChunkType.zTXt, ChunkType.iTXt, ChunkType.eXIf };
+        final List<PngChunk> chunks = readChunks(byteSource, chunkTypes, false);
 
         if (chunks.isEmpty()) {
             return null;
         }
 
-        final GenericImageMetadata result = new GenericImageMetadata();
+        final GenericImageMetadata textual = new GenericImageMetadata();
+        TiffImageMetadata exif = null;
 
         for (final PngChunk chunk : chunks) {
-            final PngTextChunk textChunk = (PngTextChunk) chunk;
+            if (chunk instanceof PngTextChunk) {
+                final PngTextChunk textChunk = (PngTextChunk) chunk;
+                textual.add(textChunk.getKeyword(), textChunk.getText());
+            } else if (chunk.chunkType == ChunkType.eXIf.value) {
+                if (exif != null) {
+                    throw new ImageReadException("Duplicate eXIf chunk");
+                }
+                exif = (TiffImageMetadata) new TiffImageParser().getMetadata(chunk.getBytes());
+            }

Review Comment:
   I think we should either log and/or raise an error for any other type here.



##########
src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java:
##########
@@ -187,29 +190,7 @@ private List<PngChunk> readChunks(final InputStream is, final ChunkType[] chunkT
             final int crc = read4Bytes("CRC", is, "Not a Valid PNG File", getByteOrder());
 
             if (keep) {
-                if (chunkType == ChunkType.iCCP.value) {
-                    result.add(new PngChunkIccp(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.tEXt.value) {
-                    result.add(new PngChunkText(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.zTXt.value) {
-                    result.add(new PngChunkZtxt(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.IHDR.value) {
-                    result.add(new PngChunkIhdr(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.PLTE.value) {
-                    result.add(new PngChunkPlte(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.pHYs.value) {
-                    result.add(new PngChunkPhys(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.sCAL.value) {
-                    result.add(new PngChunkScal(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.IDAT.value) {
-                    result.add(new PngChunkIdat(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.gAMA.value) {
-                    result.add(new PngChunkGama(length, chunkType, crc, bytes));
-                } else if (chunkType == ChunkType.iTXt.value) {
-                    result.add(new PngChunkItxt(length, chunkType, crc, bytes));
-                } else {
-                    result.add(new PngChunk(length, chunkType, crc, bytes));
-                }
+                result.add(ChunkType.makeChunk(length, chunkType, crc, bytes));

Review Comment:
   :ok_man: :clap:  bravo, @Glavo 



##########
src/main/java/org/apache/commons/imaging/formats/png/PngImageMetadata.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.imaging.formats.png;
+
+import org.apache.commons.imaging.common.ImageMetadata;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.internal.Debug;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+public class PngImageMetadata implements ImageMetadata {

Review Comment:
   Can you add javadocs to the new public classes/methods/fields/etc, please? Doesn't need to be long, but we need a `@since $current-snapshot-version-minus-snapshot` here and in the public members added to existing code.



##########
src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java:
##########
@@ -282,21 +263,53 @@ public Dimension getImageSize(final ByteSource byteSource, final PngImagingParam
     @Override
     public ImageMetadata getMetadata(final ByteSource byteSource, final PngImagingParameters params)
             throws ImageReadException, IOException {
-        final List<PngChunk> chunks = readChunks(byteSource, new ChunkType[] { ChunkType.tEXt, ChunkType.zTXt, ChunkType.iTXt }, false);
+        final ChunkType[] chunkTypes = { ChunkType.tEXt, ChunkType.zTXt, ChunkType.iTXt, ChunkType.eXIf };
+        final List<PngChunk> chunks = readChunks(byteSource, chunkTypes, false);
 
         if (chunks.isEmpty()) {
             return null;
         }
 
-        final GenericImageMetadata result = new GenericImageMetadata();
+        final GenericImageMetadata textual = new GenericImageMetadata();
+        TiffImageMetadata exif = null;
 
         for (final PngChunk chunk : chunks) {
-            final PngTextChunk textChunk = (PngTextChunk) chunk;
+            if (chunk instanceof PngTextChunk) {
+                final PngTextChunk textChunk = (PngTextChunk) chunk;
+                textual.add(textChunk.getKeyword(), textChunk.getText());
+            } else if (chunk.chunkType == ChunkType.eXIf.value) {
+                if (exif != null) {
+                    throw new ImageReadException("Duplicate eXIf chunk");
+                }
+                exif = (TiffImageMetadata) new TiffImageParser().getMetadata(chunk.getBytes());
+            }
+        }
 
-            result.add(textChunk.getKeyword(), textChunk.getText());
+        return new PngImageMetadata(textual, exif);
+    }
+
+    public TiffImageMetadata getExifMetadata(final ByteSource byteSource, TiffImagingParameters params)
+            throws ImageReadException, IOException {
+        final byte[] bytes = getExifRawData(byteSource);
+        if (null == bytes) {
+            return null;
         }
 
-        return result;
+        if (params == null) {
+            params = new TiffImagingParameters();
+        }
+
+        return (TiffImageMetadata) new TiffImageParser().getMetadata(bytes, params);
+    }
+
+    public byte[] getExifRawData(final ByteSource byteSource) throws ImageReadException, IOException {

Review Comment:
   Docs for new public members with the `@since` tag, please :+1: 



-- 
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] Glavo commented on pull request #269: [IMAGING-340] Support PNG extension

Posted by GitBox <gi...@apache.org>.
Glavo commented on PR #269:
URL: https://github.com/apache/commons-imaging/pull/269#issuecomment-1383153151

   The javadoc has been updated to add the `@since` tag.


-- 
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


Re: [PR] [IMAGING-340] Support PNG extension [commons-imaging]

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

   > I don’t know if this PR will ever be pulled, because by now I think that this project is pretty much dead.
   
   Certainly not dead. Maintained by volunteers, yes. I am busy with deadlines at work, but watching and planning  a future development cycle, fix security bugs (a lot happens there without activity on GitHub for a reason, so again, not dead).
   
   I think it is good to have more projects like what you created to give more options to users.
   
   But leave a comment saying a project is dead and promote your own tool doesn't look very good, IMHO.
   
   And apologies again for the radio silence, just busy with $work and not able to volunteer time at this point (happy if any other committer takes over, otherwise March I should be available).
   
   Cheers


-- 
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] Glavo commented on pull request #269: [WIP] Support PNG extension

Posted by GitBox <gi...@apache.org>.
Glavo commented on PR #269:
URL: https://github.com/apache/commons-imaging/pull/269#issuecomment-1381268135

   > FYI, this will not be considered without unit tests.
   
   Before that, I need to find a way to generate test data.
   The new extension lacks tool support. I think I may need to use libpng directly to generate test data.


-- 
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 pull request #269: [WIP] Support PNG extension

Posted by GitBox <gi...@apache.org>.
garydgregory commented on PR #269:
URL: https://github.com/apache/commons-imaging/pull/269#issuecomment-1381258822

   FYI, this will not be considered without unit tests.


-- 
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] Glavo commented on pull request #269: [WIP] [IMAGING-340] Support PNG extension

Posted by GitBox <gi...@apache.org>.
Glavo commented on PR #269:
URL: https://github.com/apache/commons-imaging/pull/269#issuecomment-1381983655

   When I created the test, I noticed the type of `EXIF_TAG_EXIF_IMAGE_WIDTH` and `EXIF_TAG_EXIF_IMAGE_LENGTH` is `TagInfoShort`.
   
   However, in the [standard document](https://www.cipa.jp/std/documents/e/DC-X008-Translation-2019-E.pdf), the field type is SHORT or LONG.
   
   Unfortunately, the test image I found uses the LONG type field to record `ExifImageWidth` and `ExifImageLength`, so I found this problem.
   
   Should I solve this problem in this PR? Or do I need to open a new PR?


-- 
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


Re: [PR] [IMAGING-340] Support PNG extension [commons-imaging]

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

   @Glavo Thank you!
   
   I don’t know if this PR will ever be pulled, because by now I think that this project is pretty much dead.
   
   But you did not waste your time on this, because I pulled it into my Kotlin port [Ashampoo Kim](https://github.com/ashampoo/kim). So you may be glad to hear that your code is used in production (for example by [Ashampoo Photos](https://www.ashampoo.com/photos)) and people benefit from it. 🙂
   
   I invite you to contribute directly to my fork in the future.


-- 
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