[jira] [Work logged] (IMAGING-340) Support PNG extension

2023-01-15 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-340?focusedWorklogId=839271=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-839271
 ]

ASF GitHub Bot logged work on IMAGING-340:
--

Author: ASF GitHub Bot
Created on: 15/Jan/23 13:39
Start Date: 15/Jan/23 13:39
Worklog Time Spent: 10m 
  Work Description: 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.




Issue Time Tracking
---

Worklog Id: (was: 839271)
Time Spent: 40m  (was: 0.5h)

> Support PNG extension
> -
>
> Key: IMAGING-340
> URL: https://issues.apache.org/jira/browse/IMAGING-340
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: Format: PNG
>Reporter: Glavo
>Priority: Minor
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (IMAGING-340) Support PNG extension

2023-01-15 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-340?focusedWorklogId=839270=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-839270
 ]

ASF GitHub Bot logged work on IMAGING-340:
--

Author: ASF GitHub Bot
Created on: 15/Jan/23 13:31
Start Date: 15/Jan/23 13:31
Worklog Time Spent: 10m 
  Work Description: 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.
+ * 
+ * The implementation is based on the
+ * http://www.libpng.org/pub/png/spec/1.2/;>PNG specification version 
1.2,
+ * and supports the following extensions:
+ * 
+ * http://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html;>Extensions
 to the PNG 1.2 Specification, Version 1.5.0
+ * 

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

[jira] [Work logged] (IMAGING-340) Support PNG extension

2023-01-14 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-340?focusedWorklogId=839253=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-839253
 ]

ASF GitHub Bot logged work on IMAGING-340:
--

Author: ASF GitHub Bot
Created on: 15/Jan/23 01:58
Start Date: 15/Jan/23 01:58
Worklog Time Spent: 10m 
  Work Description: 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?




Issue Time Tracking
---

Worklog Id: (was: 839253)
Time Spent: 20m  (was: 10m)

> Support PNG extension
> -
>
> Key: IMAGING-340
> URL: https://issues.apache.org/jira/browse/IMAGING-340
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: Format: PNG
>Reporter: Glavo
>Priority: Minor
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (IMAGING-340) Support PNG extension

2023-01-13 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-340?focusedWorklogId=839098=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-839098
 ]

ASF GitHub Bot logged work on IMAGING-340:
--

Author: ASF GitHub Bot
Created on: 13/Jan/23 14:59
Start Date: 13/Jan/23 14:59
Worklog Time Spent: 10m 
  Work Description: 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?




Issue Time Tracking
---

Worklog Id: (was: 839098)
Remaining Estimate: 0h
Time Spent: 10m

> Support PNG extension
> -
>
> Key: IMAGING-340
> URL: https://issues.apache.org/jira/browse/IMAGING-340
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: Format: PNG
>Reporter: Glavo
>Priority: Minor
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)