[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 16/Jan/22 02:03
Start Date: 16/Jan/22 02:03
Worklog Time Spent: 10m 
  Work Description: kinow merged pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116


   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709588)
Time Spent: 20h 10m  (was: 20h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 20h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 16/Jan/22 00:46
Start Date: 16/Jan/22 00:46
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-1013783823


   Woohoo! I vote to merge it!


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709585)
Time Spent: 20h  (was: 19h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 20h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 15/Jan/22 21:43
Start Date: 15/Jan/22 21:43
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-1013758565


   @darkma773r applied all changes exactly as suggested, and created two 
follow-up JIRA issues. Unless there are any last minute review requests, I 
think we are ready to merge it! :tada: 
   
   Thanks a lot @darkma773r , @gwlucastrig , and also @britter who managed the 
first release vote and created the issue for parameters. I remember all effort 
put into moving from sanselan to imaging and then the 1.0 work, which we should 
be ready to prepare a final release soon. Really appreciate it :bow: 
   
   -Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709568)
Time Spent: 19h 50m  (was: 19h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 19h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 15/Jan/22 21:31
Start Date: 15/Jan/22 21:31
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r785353990



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -563,27 +561,22 @@ public final BufferedImage getBufferedImage(final File 
file, final MapThe params argument provides a mechanism for individual
  * implementations to pass optional information into the parser.
  * Not all formats will support this capability.  Currently,
- * some of the parsers do not check for null arguments. So in cases
- * where no optional specifications are supported, application
- * code should pass in an empty instance of an implementation of
- * the map interface (i.e. an empty HashMap).
+ * some of the parsers do not check for null arguments.

Review comment:
   Done! https://issues.apache.org/jira/browse/IMAGING-323




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709567)
Time Spent: 19h 40m  (was: 19.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 19h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 15/Jan/22 21:28
Start Date: 15/Jan/22 21:28
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r785353746



##
File path: src/main/java/org/apache/commons/imaging/ImageFormat.java
##
@@ -33,6 +34,7 @@
  *
  * @return String extension
  */
-String getExtension();
+String[] getExtensions();

Review comment:
   Tentative fix version set to alpha 3, or it might be done for 1.0 final 
release: https://issues.apache.org/jira/browse/IMAGING-322




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709566)
Time Spent: 19.5h  (was: 19h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 19.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 15/Jan/22 21:21
Start Date: 15/Jan/22 21:21
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r785353218



##
File path: src/main/java/org/apache/commons/imaging/internal/Util.java
##
@@ -0,0 +1,73 @@
+/*
+ * 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.internal;
+
+import org.apache.commons.imaging.ImageFormat;
+import org.apache.commons.imaging.ImageFormats;
+import org.apache.commons.imaging.ImageParser;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.ImagingParameters;
+import org.apache.commons.imaging.common.bytesource.ByteSource;
+
+import java.io.IOException;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/**
+ * Internal utilities.
+ *
+ * @since 1.0-alpha3
+ */
+public class Util {
+
+private Util() {}
+
+public static  ImageParser 
getImageParser(ImageFormat format) {
+return getImageParser((parser) -> parser.canAcceptType(format), () -> 
new RuntimeException("Unknown Format: " + format));
+}
+
+public static  ImageParser 
getImageParser(String fileExtension) {
+return getImageParser((parser) -> 
parser.canAcceptExtension(fileExtension), () -> new RuntimeException("Unknown 
Extension: " + fileExtension));

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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709564)
Time Spent: 19h 20m  (was: 19h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 19h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 15/Jan/22 21:18
Start Date: 15/Jan/22 21:18
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r785353011



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -955,18 +944,15 @@ protected BufferedImageFactory 
getBufferedImageFactory(final Map
 
 /**
  * A utility method to search a params specification and determine
- * whether it contains the ImagingConstants.PARAM_KEY_STRICT
- * specification. Intended
+ * whether it contains the parameters contain the strict flag. Intended
  * for internal use by ImageParser implementations.
  *
- * @param params A valid Map object (or a null).
+ * @param params optional parameters.
  * @return If the params specify strict format compliance, true;
  * otherwise, false.
+ * @param  type of parameters used by this image parser
  */
-public static boolean isStrict(final Map params) {
-if (params == null || 
!params.containsKey(ImagingConstants.PARAM_KEY_STRICT)) {
-return false;
-}
-return ((Boolean) 
params.get(ImagingConstants.PARAM_KEY_STRICT)).booleanValue();
+public static  boolean isStrict(final T 
params) {
+return params.isStrict();

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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709563)
Time Spent: 19h 10m  (was: 19h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 19h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 15/Jan/22 19:32
Start Date: 15/Jan/22 19:32
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r785344916



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -563,27 +561,22 @@ public final BufferedImage getBufferedImage(final File 
file, final MapThe params argument provides a mechanism for individual
  * implementations to pass optional information into the parser.
  * Not all formats will support this capability.  Currently,
- * some of the parsers do not check for null arguments. So in cases
- * where no optional specifications are supported, application
- * code should pass in an empty instance of an implementation of
- * the map interface (i.e. an empty HashMap).
+ * some of the parsers do not check for null arguments.

Review comment:
   Good idea! Will create it now.




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 709556)
Time Spent: 19h  (was: 18h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 19h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

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


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

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

Author: ASF GitHub Bot
Created on: 15/Jan/22 19:24
Start Date: 15/Jan/22 19:24
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r785343858



##
File path: src/main/java/org/apache/commons/imaging/internal/Util.java
##
@@ -0,0 +1,54 @@
+/*
+ * 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.internal;
+
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+import org.apache.commons.imaging.ImageFormat;
+import org.apache.commons.imaging.ImageParser;
+import org.apache.commons.imaging.ImagingParameters;
+
+/**
+ * Internal utilities.
+ *
+ * @since 1.0-alpha3
+ */
+public class Util {
+
+private Util() {}
+
+public static  ImageParser 
getImageParser(ImageFormat format) {
+return getImageParser((parser) -> parser.canAcceptType(format), () -> 
new RuntimeException("Unknown Format: " + format));
+}
+
+public static  ImageParser 
getImageParser(String fileExtension) {
+return getImageParser((parser) -> 
parser.canAcceptExtension(fileExtension), () -> new RuntimeException("Unknown 
Extension: " + fileExtension));
+}
+
+// This generics suppression is as good as the predicate given. If the 
predicate violates a generics design,
+// then there will be an error during runtime.
+@SuppressWarnings("unchecked")
+private static  ImageParser 
getImageParser(Predicate> pred, Supplier supl) {
+return (ImageParser) ImageParser
+.getAllImageParsers()
+.stream()
+.filter((parser) -> pred.test(parser))
+.findFirst()

Review comment:
   The generic parameter T is actually not needed with the way this method 
is being used. Removing the `` part of the 
signatures here and just returning `ImageParser` for all of them removes the 
need for the warning suppression.

##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -563,27 +561,22 @@ public final BufferedImage getBufferedImage(final File 
file, final MapThe params argument provides a mechanism for individual
  * implementations to pass optional information into the parser.
  * Not all formats will support this capability.  Currently,
- * some of the parsers do not check for null arguments. So in cases
- * where no optional specifications are supported, application
- * code should pass in an empty instance of an implementation of
- * the map interface (i.e. an empty HashMap).
+ * some of the parsers do not check for null arguments.

Review comment:
   Should there be a future issue to make sure that all parsers check for 
null?

##
File path: src/main/java/org/apache/commons/imaging/Imaging.java
##
@@ -50,62 +48,40 @@
  *
  * Using this class
  *
- * 
- * Almost all of the Apache Commons Imaging library's core functionality can
+ * Almost all of the Apache Commons Imaging library's core functionality can
  * be accessed through the methods provided by this class.
  * The use of the Imaging class is similar to the Java API's ImageIO class,
- * though Imaging supports formats and options not included in the standard
- * Java API.
- * 
+ * though Imaging supports formats not included in the standard Java API.
  *
- * 
- * All of methods provided by the Imaging class are declared static.
- * 
+ * All of methods provided by the Imaging class are declared static.
  *
- * 
- * The Apache Commons Imaging package is a pure Java implementation.
- * 
+ * The Apache Commons Imaging package is a pure Java implementation.
  *
  * Format support
  *
- * 
- * While the Apache Commons Imaging package handles a number of different
+ * While the Apache Commons Imaging package handles a number of different
  * graphics formats, support for some 

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-09 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 09/Jan/22 21:36
Start Date: 09/Jan/22 21:36
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-1008428517


   Not a problem @darkma773r , I'll work on other things, including trying to 
look at that fuzzy-search issue GEOMETRY-142. Thanks!!!


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705848)
Time Spent: 18h 40m  (was: 18.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 18h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-09 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 09/Jan/22 21:14
Start Date: 09/Jan/22 21:14
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-1008425078


   Awesome, @kinow! I'll take a look at this as soon as I get some time. 
Unfortunately, that probably won't be for at least a few more days.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705845)
Time Spent: 18.5h  (was: 18h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 18.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-08 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Jan/22 10:29
Start Date: 08/Jan/22 10:29
Worklog Time Spent: 10m 
  Work Description: gwlucastrig edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841791184


   It looks like providing compatibility with Android OS may not be practical.
   Android has its own graphics and media classes.  So anything with java.awt
   in it will not port. Common Imaging using BufferedImage extensively.   Most
   other AWT elements are used only a little.  Color shows up the most.  The
   ICC_ColorSpace also shows up. A couple of the test applications use
   Graphics to draw some test images as input.
   
   I think I might post a question on Java Coderanch or Stackoverflow to ask
   about compatible solutions.
   
   
   On Sat, May 15, 2021 at 8:18 AM Bruno P. Kinoshita ***@***.***>
   wrote:
   
   > If those classes are from awt, the issue is that we have a dependency to
   > java.desktop (I think that's the java module name) and also cause an issue
   > to users of the API that are using Android (as IIUC, there's no awt in
   > Android's Java SDK?).
   >
   > —
   > You are receiving this because you were mentioned.
   > Reply to this email directly, view it on GitHub
   > 
,
   > or unsubscribe
   > 

   > .
   >
   
   
   Search "java.awt" (229 hits in 121 files of 557 searched)
   
   commons-imaging\src\main\java\org\apache\commons\imaging\ColorTools.java (11 
hits)
Line 20: import java.awt.RenderingHints;
Line 21: import java.awt.Transparency;
Line 22: import java.awt.color.ColorSpace;
Line 23: import java.awt.color.ICC_ColorSpace;
Line 24: import java.awt.color.ICC_Profile;
Line 25: import java.awt.image.BufferedImage;
Line 26: import java.awt.image.ColorConvertOp;
Line 27: import java.awt.image.ColorModel;
Line 28: import java.awt.image.ComponentColorModel;
Line 29: import java.awt.image.DirectColorModel;
Line 30: import java.awt.image.ImagingOpException;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\BufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\ImageBuilder.java
 (9 hits)
Line 43: import java.awt.color.ColorSpace;
Line 44: import java.awt.image.BufferedImage;
Line 45: import java.awt.image.ColorModel;
Line 46: import java.awt.image.DataBuffer;
Line 47: import java.awt.image.DataBufferInt;
Line 48: import java.awt.image.DirectColorModel;
Line 49: import java.awt.image.Raster;
Line 50: import java.awt.image.RasterFormatException;
Line 51: import java.awt.image.WritableRaster;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\RgbBufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\SimpleBufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpImageParser.java
 (2 hits)
Line 27: import java.awt.Dimension;
Line 28: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriter.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriterPalette.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriterRgb.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\dcx\DcxImageParser.java
 (2 hits)
Line 23: import java.awt.Dimension;
Line 24: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\gif\GifImageParser.java
 (2 hits)
Line 28: import java.awt.Dimension;
Line 29: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\icns\IcnsDecoder.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\icns\IcnsImageParser.java
 (2 hits)
Line 23: import java.awt.Dimension;
Line 24: import ja

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-08 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Jan/22 10:25
Start Date: 08/Jan/22 10:25
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r780503881



##
File path: src/main/java/org/apache/commons/imaging/Imaging.java
##
@@ -50,62 +48,40 @@
  *
  * Using this class
  *
- * 
- * Almost all of the Apache Commons Imaging library's core functionality can
+ * Almost all of the Apache Commons Imaging library's core functionality can
  * be accessed through the methods provided by this class.
  * The use of the Imaging class is similar to the Java API's ImageIO class,
- * though Imaging supports formats and options not included in the standard
- * Java API.
- * 
+ * though Imaging supports formats not included in the standard Java API.
  *
- * 
- * All of methods provided by the Imaging class are declared static.
- * 
+ * All of methods provided by the Imaging class are declared static.
  *
- * 
- * The Apache Commons Imaging package is a pure Java implementation.
- * 
+ * The Apache Commons Imaging package is a pure Java implementation.
  *
  * Format support
  *
- * 
- * While the Apache Commons Imaging package handles a number of different
+ * While the Apache Commons Imaging package handles a number of different
  * graphics formats, support for some formats is not yet complete.
  * For the most recent information on support for specific formats, refer to
  * https://commons.apache.org/imaging/formatsupport.html";>Format 
Support
- * at the main project development web site.
- * 
+ * at the main project development web site.
  *
  * Optional parameters for image reading and writing
  *
- * 
- * Some of the methods provided by this class accept an optional
- * params argument that permits the application to specify
- * elements for special handling.  If these specifications are not required by
- * the application, the params argument may be omitted (as appropriate) or
- * a null argument may be provided. In image-writing operations, the option
- * parameters may include options such as data-compression type (if any),
- * color model, or other format-specific data representations.   The parameters
- * map may also be used to provide EXIF Tags and other metadata to those
- * formats that support them. In image-reading operations,
- * the parameters may include information about special handling in reading
- * the image data.
- * 
+ * Many of the operations provided in this class as static calls can be 
accessed directly
+ * using {@link ImageParser}'s. It is, however, difficult to design an API 
that is generic
+ * enough so users can safely read or write byte arrays when specifying the 
type of parameters,
+ * since the only way to confirm the parameters are valid for a specific 
format is by reading
+ * the byte array (when it is already too late.)

Review comment:
   **N.B.** we are removing the public methods of `Imaging`, and updating 
the docs here. Now users must use the `ImageParser` classes directly if they 
want to customize how to read/write images.
   
   This reduced a lot the size of `Imaging`. I think this prevents issues we 
have in [lang] where some classes grow longer and longer as more features are 
added - in our case it would grow by 3-4 methods (one for `File`, one for 
`ByteSource`, one for `bytes`, etc) for each new image file format added to 
[imaging].
   
   And, of course, that solves the issue of trying to prevent 
`ClassCastException`'s, generics, and trying to create a good API for users in 
`Imaging`.

##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * 

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-08 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Jan/22 10:22
Start Date: 08/Jan/22 10:22
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-1007768801


   @gwlucastrig , @darkma773r I believe this is ready for review again. And I 
think it is really close to being ready to be merged! :tada: 
   
   @darkma773r I've removed the `Imaging` public methods that used 
`ImagingParameter`'s (and `Hashmap`'s before). This reduced the amount of 
public methods in `Imaging`, and later we can decide whether to add back 
methods with Parameter factories/builders/mergers/etc, or create builders in 
each parsers, or improve the parsers' API'...
   
   After rebasing, there was a bit of Javadoc errors, probably from recent 
plug-in versions. Fixed those too, reviewed the code removing unnecessary 
changes, and finally added the `changes.xml` entry. With this, leaving the 126 
modified files for you guys to review :smile: (sorry!)
   
   Thanks a lot for the help,
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705592)
Time Spent: 18h  (was: 17h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 18h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-08 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Jan/22 10:11
Start Date: 08/Jan/22 10:11
Worklog Time Spent: 10m 
  Work Description: kinow edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-826703877


   Note to self: 
   
   - [x] rebase again
   - [x] check Tabs vs. Spaces
   - [x] great suggestion from @gwlucastrig : "use one call for setSubImage, 
rather than 4 separate calls for setSubImageX, Y, Width, Height."


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705477)
Time Spent: 17h 50m  (was: 17h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 17h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 07/Jan/22 21:58
Start Date: 07/Jan/22 21:58
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r780552113



##
File path: src/changes/changes.xml
##
@@ -45,6 +45,21 @@ The  type attribute can be add,update,fix,remove.
   
   
 
+  

Review comment:
   Thanks for the help!!!  :point_up: :bowing_man: 




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705286)
Time Spent: 17h 40m  (was: 17.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 17h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 07/Jan/22 21:58
Start Date: 07/Jan/22 21:58
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r780552113



##
File path: src/changes/changes.xml
##
@@ -45,6 +45,21 @@ The  type attribute can be add,update,fix,remove.
   
   
 
+  

Review comment:
   Thanks for the help!!! :tada: 

##
File path: src/changes/changes.xml
##
@@ -45,6 +45,21 @@ The  type attribute can be add,update,fix,remove.
   
   
 
+  

Review comment:
   Thanks for the help!!! :tada: :point_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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705285)
Time Spent: 17.5h  (was: 17h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 17.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 07/Jan/22 21:57
Start Date: 07/Jan/22 21:57
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-1007768801


   @gwlucastrig , @darkma773r I believe this is ready for review again. And I 
think it is really close to being ready to be merged! :tada: 
   
   @darkma773r I've removed the `Imaging` public methods that used 
`ImagingParameter`'s (and `Hashmap`'s before). This reduced the amount of 
public methods in `Imaging`, and later we can decide whether to add back 
methods with Parameter factories/builders/mergers/etc, or create builders in 
each parsers, or improve the parsers' API'...
   
   After rebasing, there was a bit of Javadoc errors, probably from recent 
plug-in versions. Fixed those too, reviewed the code removing unnecessary 
changes, and finally added the `changes.xml` entry. With this, leaving the 126 
modified files for you guys to review :smile: (sorry!)
   
   Thanks a lot for the help,
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705284)
Time Spent: 17h 20m  (was: 17h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 17h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 07/Jan/22 21:53
Start Date: 07/Jan/22 21:53
Worklog Time Spent: 10m 
  Work Description: kinow edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-826703877


   Note to self: 
   
   - [x] rebase again
   - [x] check Tabs vs. Spaces
   - [x] great suggestion from @gwlucastrig : "use one call for setSubImage, 
rather than 4 separate calls for setSubImageX, Y, Width, Height."


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705281)
Time Spent: 17h 10m  (was: 17h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 17h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 07/Jan/22 21:04
Start Date: 07/Jan/22 21:04
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r780528232



##
File path: src/main/java/org/apache/commons/imaging/Imaging.java
##
@@ -857,20 +837,19 @@ public static Dimension getImageSize(final File file) 
throws ImageReadException,
  *
  * @param file
  *File containing image data.
- * @param params
- *Map of optional parameters, defined in ImagingConstants.
+ * @param params optional parameters.
  * @return The width and height of the image.
  * @throws ImageReadException if it fails to parse the image
  * @throws IOException if it fails to read the image data
  */
-public static Dimension getImageSize(final File file, final Map params)
+public static Dimension getImageSize(final File file, final 
ImagingParameters params)

Review comment:
   @darkma773r I went with option 2. It reduces the `Imaging.java` size, 
and prevents the god-class issue in  case we added more image formats later. 
IMHO, it will be simpler to either improve the `ImageParser`'s API, or think in 
how to better handle parameters in the `Imaging` class (like merging 
parameters, of providing factories as you suggested).
   
   But for 1.0 this should be better than the old `Hashmap`, and avoid runtime 
exceptions. Thank you!!!




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 705251)
Time Spent: 17h  (was: 16h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 17h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 07/Jan/22 21:02
Start Date: 07/Jan/22 21:02
Worklog Time Spent: 10m 
  Work Description: gwlucastrig edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841791184


   It looks like providing compatibility with Android OS may not be practical.
   Android has its own graphics and media classes.  So anything with java.awt
   in it will not port. Common Imaging using BufferedImage extensively.   Most
   other AWT elements are used only a little.  Color shows up the most.  The
   ICC_ColorSpace also shows up. A couple of the test applications use
   Graphics to draw some test images as input.
   
   I think I might post a question on Java Coderanch or Stackoverflow to ask
   about compatible solutions.
   
   
   On Sat, May 15, 2021 at 8:18 AM Bruno P. Kinoshita ***@***.***>
   wrote:
   
   > If those classes are from awt, the issue is that we have a dependency to
   > java.desktop (I think that's the java module name) and also cause an issue
   > to users of the API that are using Android (as IIUC, there's no awt in
   > Android's Java SDK?).
   >
   > —
   > You are receiving this because you were mentioned.
   > Reply to this email directly, view it on GitHub
   > 
,
   > or unsubscribe
   > 

   > .
   >
   
   
   Search "java.awt" (229 hits in 121 files of 557 searched)
   
   commons-imaging\src\main\java\org\apache\commons\imaging\ColorTools.java (11 
hits)
Line 20: import java.awt.RenderingHints;
Line 21: import java.awt.Transparency;
Line 22: import java.awt.color.ColorSpace;
Line 23: import java.awt.color.ICC_ColorSpace;
Line 24: import java.awt.color.ICC_Profile;
Line 25: import java.awt.image.BufferedImage;
Line 26: import java.awt.image.ColorConvertOp;
Line 27: import java.awt.image.ColorModel;
Line 28: import java.awt.image.ComponentColorModel;
Line 29: import java.awt.image.DirectColorModel;
Line 30: import java.awt.image.ImagingOpException;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\BufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\ImageBuilder.java
 (9 hits)
Line 43: import java.awt.color.ColorSpace;
Line 44: import java.awt.image.BufferedImage;
Line 45: import java.awt.image.ColorModel;
Line 46: import java.awt.image.DataBuffer;
Line 47: import java.awt.image.DataBufferInt;
Line 48: import java.awt.image.DirectColorModel;
Line 49: import java.awt.image.Raster;
Line 50: import java.awt.image.RasterFormatException;
Line 51: import java.awt.image.WritableRaster;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\RgbBufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\SimpleBufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpImageParser.java
 (2 hits)
Line 27: import java.awt.Dimension;
Line 28: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriter.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriterPalette.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriterRgb.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\dcx\DcxImageParser.java
 (2 hits)
Line 23: import java.awt.Dimension;
Line 24: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\gif\GifImageParser.java
 (2 hits)
Line 28: import java.awt.Dimension;
Line 29: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\icns\IcnsDecoder.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\icns\IcnsImageParser.java
 (2 hits)
Line 23: import java.awt.Dimension;
Line 24: import ja

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 07/Jan/22 20:55
Start Date: 07/Jan/22 20:55
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r780503881



##
File path: src/main/java/org/apache/commons/imaging/Imaging.java
##
@@ -50,62 +48,40 @@
  *
  * Using this class
  *
- * 
- * Almost all of the Apache Commons Imaging library's core functionality can
+ * Almost all of the Apache Commons Imaging library's core functionality can
  * be accessed through the methods provided by this class.
  * The use of the Imaging class is similar to the Java API's ImageIO class,
- * though Imaging supports formats and options not included in the standard
- * Java API.
- * 
+ * though Imaging supports formats not included in the standard Java API.
  *
- * 
- * All of methods provided by the Imaging class are declared static.
- * 
+ * All of methods provided by the Imaging class are declared static.
  *
- * 
- * The Apache Commons Imaging package is a pure Java implementation.
- * 
+ * The Apache Commons Imaging package is a pure Java implementation.
  *
  * Format support
  *
- * 
- * While the Apache Commons Imaging package handles a number of different
+ * While the Apache Commons Imaging package handles a number of different
  * graphics formats, support for some formats is not yet complete.
  * For the most recent information on support for specific formats, refer to
  * https://commons.apache.org/imaging/formatsupport.html";>Format 
Support
- * at the main project development web site.
- * 
+ * at the main project development web site.
  *
  * Optional parameters for image reading and writing
  *
- * 
- * Some of the methods provided by this class accept an optional
- * params argument that permits the application to specify
- * elements for special handling.  If these specifications are not required by
- * the application, the params argument may be omitted (as appropriate) or
- * a null argument may be provided. In image-writing operations, the option
- * parameters may include options such as data-compression type (if any),
- * color model, or other format-specific data representations.   The parameters
- * map may also be used to provide EXIF Tags and other metadata to those
- * formats that support them. In image-reading operations,
- * the parameters may include information about special handling in reading
- * the image data.
- * 
+ * Many of the operations provided in this class as static calls can be 
accessed directly
+ * using {@link ImageParser}'s. It is, however, difficult to design an API 
that is generic
+ * enough so users can safely read or write byte arrays when specifying the 
type of parameters,
+ * since the only way to confirm the parameters are valid for a specific 
format is by reading
+ * the byte array (when it is already too late.)

Review comment:
   **N.B.** we are removing the public methods of `Imaging`, and updating 
the docs here. Now users must use the `ImageParser` classes directly if they 
want to customize how to read/write images.
   
   This reduced a lot the size of `Imaging`. I think this prevents issues we 
have in [lang] where some classes grow longer and longer as more features are 
added - in our case it would grow by 3-4 methods (one for `File`, one for 
`ByteSource`, one for `bytes`, etc) for each new image file format added to 
[imaging].
   
   And, of course, that solves the issue of trying to prevent 
`ClassCastException`'s, generics, and trying to create a good API for users in 
`Imaging`.

##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * 

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Jan/22 05:38
Start Date: 03/Jan/22 05:38
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r777299737



##
File path: 
src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImagingParameters.java
##
@@ -0,0 +1,24 @@
+/*
+ *  Licensed 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.
+ *  under the License.
+ */
+
+package org.apache.commons.imaging.formats.jpeg;
+
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+
+/**
+ * Jpeg format parameters.
+ * @since 1.0-alpha3
+ */
+public class JpegImagingParameters extends TiffImagingParameters {}

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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 702850)
Time Spent: 16.5h  (was: 16h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 16.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Jan/22 02:08
Start Date: 03/Jan/22 02:08
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-1003833509


   Rebased and addressed some of the excellent feedback. Thanks @darkma773r !
   
   I'm looking at the JPEG & TIFF relationship issue as that's easier to fix. 
Then I think we will have the last issue, of ClassCastException, and the public 
methods of `Imaging`.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 702840)
Time Spent: 16h 20m  (was: 16h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 16h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Jan/22 02:06
Start Date: 03/Jan/22 02:06
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r777276289



##
File path: 
src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImagingParameters.java
##
@@ -0,0 +1,24 @@
+/*
+ *  Licensed 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.
+ *  under the License.
+ */
+
+package org.apache.commons.imaging.formats.jpeg;
+
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+
+/**
+ * Jpeg format parameters.
+ * @since 1.0-alpha3
+ */
+public class JpegImagingParameters extends TiffImagingParameters {}

Review comment:
   At the moment, due to how the classes are structured, I believe they do. 
But I've been thinking about it since you first noticed that it was strange the 
TIFF & JPEG parsers' relationship. Let me see how the code would look like 
separating the two (with either an intermediary class playing the role of a 
mixin, or simply duplicating the 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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 702839)
Time Spent: 16h 10m  (was: 16h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 16h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Jan/22 02:04
Start Date: 03/Jan/22 02:04
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r777276089



##
File path: src/main/java/org/apache/commons/imaging/ImageFormats.java
##
@@ -16,40 +16,68 @@
  */
 package org.apache.commons.imaging;
 
+import org.apache.commons.imaging.formats.bmp.BmpImagingParameters;
+import org.apache.commons.imaging.formats.gif.GifImagingParameters;
+import org.apache.commons.imaging.formats.icns.IcnsImagingParameters;
+import org.apache.commons.imaging.formats.ico.IcoImagingParameters;
+import org.apache.commons.imaging.formats.jpeg.JpegImagingParameters;
+import org.apache.commons.imaging.formats.pcx.PcxImagingParameters;
+import org.apache.commons.imaging.formats.png.PngImagingParameters;
+import org.apache.commons.imaging.formats.pnm.PnmImagingParameters;
+import org.apache.commons.imaging.formats.psd.PsdImagingParameters;
+import org.apache.commons.imaging.formats.rgbe.RgbeImagingParameters;
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+import org.apache.commons.imaging.formats.wbmp.WbmpImagingParameters;
+import org.apache.commons.imaging.formats.xbm.XbmImagingParameters;
+import org.apache.commons.imaging.formats.xpm.XpmImagingParameters;
+
+import java.util.function.Supplier;
+
 /**
  * Enum of known image formats.
  */
 public enum ImageFormats implements ImageFormat {
-UNKNOWN,
-BMP,
-DCX,
-GIF,
-ICNS,
-ICO,
-JBIG2,
-JPEG,
-PAM,
-PSD,
-PBM,
-PGM,
-PNM,
-PPM,
-PCX,
-PNG,
-RGBE,
-TGA,
-TIFF,
-WBMP,
-XBM,
-XPM;
+UNKNOWN(null),
+BMP(BmpImagingParameters::new, "bmp", "dib"),
+DCX(PcxImagingParameters::new, "dcx"),
+GIF(GifImagingParameters::new, "gif"),
+ICNS(IcnsImagingParameters::new, "icns"),
+ICO(IcoImagingParameters::new, "ico"),
+JBIG2(null),
+JPEG(JpegImagingParameters::new, "jpg", "jpeg"),
+PAM(PnmImagingParameters::new, "pam"),
+PSD(PsdImagingParameters::new, "psd"),
+PBM(PnmImagingParameters::new, "pbm"),
+PGM(PnmImagingParameters::new, "pgm"),
+PNM(PnmImagingParameters::new, "pnm"),
+PPM(PnmImagingParameters::new, "ppm"),
+PCX(PcxImagingParameters::new, "pcx", "pcc"),
+PNG(PngImagingParameters::new, "png"),
+RGBE(RgbeImagingParameters::new, "rgbe"),
+TGA(null),
+TIFF(TiffImagingParameters::new, "tif", "tiff"),
+WBMP(WbmpImagingParameters::new, "wbmp"),
+XBM(XbmImagingParameters::new, "xbm"),
+XPM(XpmImagingParameters::new, "xpm");
+
+private final String[] extensions;
+
+ImageFormats(Supplier factory, String 
...extensions) {
+this.extensions = extensions;
+}
 
 @Override
 public String getName() {
 return name();
 }
 
 @Override
-public String getExtension() {
-return name();
+public String[] getExtensions() {
+return this.extensions.clone();
+}
+
+@Override
+public String getDefaultExtension() {
+return this.extensions[0];

Review comment:
   Ouch, fixing it. Thanks!




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 702838)
Time Spent: 16h  (was: 15h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 16h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This c

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2022-01-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Jan/22 02:02
Start Date: 03/Jan/22 02:02
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r777275935



##
File path: src/main/java/org/apache/commons/imaging/ImageFormat.java
##
@@ -33,6 +34,7 @@
  *
  * @return String extension
  */
-String getExtension();
+String[] getExtensions();

Review comment:
   I started changing it, but later in the ImageParser implementations they 
are returning arrays for accepted extensions too. The commit started to grow a 
little too much, so I thought it'd be best to move it to a follow-up 
issue/discussion :+1: 

##
File path: src/main/java/org/apache/commons/imaging/ImageFormats.java
##
@@ -16,40 +16,68 @@
  */
 package org.apache.commons.imaging;
 
+import org.apache.commons.imaging.formats.bmp.BmpImagingParameters;
+import org.apache.commons.imaging.formats.gif.GifImagingParameters;
+import org.apache.commons.imaging.formats.icns.IcnsImagingParameters;
+import org.apache.commons.imaging.formats.ico.IcoImagingParameters;
+import org.apache.commons.imaging.formats.jpeg.JpegImagingParameters;
+import org.apache.commons.imaging.formats.pcx.PcxImagingParameters;
+import org.apache.commons.imaging.formats.png.PngImagingParameters;
+import org.apache.commons.imaging.formats.pnm.PnmImagingParameters;
+import org.apache.commons.imaging.formats.psd.PsdImagingParameters;
+import org.apache.commons.imaging.formats.rgbe.RgbeImagingParameters;
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+import org.apache.commons.imaging.formats.wbmp.WbmpImagingParameters;
+import org.apache.commons.imaging.formats.xbm.XbmImagingParameters;
+import org.apache.commons.imaging.formats.xpm.XpmImagingParameters;
+
+import java.util.function.Supplier;
+
 /**
  * Enum of known image formats.
  */
 public enum ImageFormats implements ImageFormat {
-UNKNOWN,
-BMP,
-DCX,
-GIF,
-ICNS,
-ICO,
-JBIG2,
-JPEG,
-PAM,
-PSD,
-PBM,
-PGM,
-PNM,
-PPM,
-PCX,
-PNG,
-RGBE,
-TGA,
-TIFF,
-WBMP,
-XBM,
-XPM;
+UNKNOWN(null),
+BMP(BmpImagingParameters::new, "bmp", "dib"),

Review comment:
   Good spot! Removed!




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 702837)
Time Spent: 15h 50m  (was: 15h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 15h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-12-04 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Dec/21 23:42
Start Date: 04/Dec/21 23:42
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-986136369


   @kinow, I have a couple of concerns about the API still. That being said, I 
don't want to single-handedly delay progress on the release, so please feel 
free to disagree with me. My main concerns are
   1. the ease of `ClassCastExceptions` being thrown on `Imaging` methods that 
accept `ImagingParameters` as arguments, and
   2. the way `JpegImagingParameters` extends`TiffImagingParameters`.
   
   We've discussed both of these before. For the first item, the simplest case 
is to just remove the methods that accept `ImagingParameters`. If we want to 
keep them, there might be promise in using the configurer callback approach, 
where the user passes a callback that accepts a parameters instance of the 
correct type (created by `ImageParser.getDefaultParameters()`) and configures 
it. Ex:
   ```java
   // ImagingParametersConfigurer.java
   @FunctionalInterface
   public ImagingParametersConfigurer {
   void configure(ImagingParameters p);
   }
   
   // Imaging.java
   public static ImageInfo getImageInfo(ByteSource bs, 
ImagingParametersConfigurer configurer) { ... }
   
   // user code
   ImageInfo info  = Imaging.getImageInfo(bs, p -> p.setStrict(true));
   ```
   
   Thanks for your tireless work on this!


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 690569)
Time Spent: 15h 40m  (was: 15.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 15h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-12-04 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Dec/21 22:59
Start Date: 04/Dec/21 22:59
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r762471491



##
File path: src/main/java/org/apache/commons/imaging/ImageFormats.java
##
@@ -16,40 +16,68 @@
  */
 package org.apache.commons.imaging;
 
+import org.apache.commons.imaging.formats.bmp.BmpImagingParameters;
+import org.apache.commons.imaging.formats.gif.GifImagingParameters;
+import org.apache.commons.imaging.formats.icns.IcnsImagingParameters;
+import org.apache.commons.imaging.formats.ico.IcoImagingParameters;
+import org.apache.commons.imaging.formats.jpeg.JpegImagingParameters;
+import org.apache.commons.imaging.formats.pcx.PcxImagingParameters;
+import org.apache.commons.imaging.formats.png.PngImagingParameters;
+import org.apache.commons.imaging.formats.pnm.PnmImagingParameters;
+import org.apache.commons.imaging.formats.psd.PsdImagingParameters;
+import org.apache.commons.imaging.formats.rgbe.RgbeImagingParameters;
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+import org.apache.commons.imaging.formats.wbmp.WbmpImagingParameters;
+import org.apache.commons.imaging.formats.xbm.XbmImagingParameters;
+import org.apache.commons.imaging.formats.xpm.XpmImagingParameters;
+
+import java.util.function.Supplier;
+
 /**
  * Enum of known image formats.
  */
 public enum ImageFormats implements ImageFormat {
-UNKNOWN,
-BMP,
-DCX,
-GIF,
-ICNS,
-ICO,
-JBIG2,
-JPEG,
-PAM,
-PSD,
-PBM,
-PGM,
-PNM,
-PPM,
-PCX,
-PNG,
-RGBE,
-TGA,
-TIFF,
-WBMP,
-XBM,
-XPM;
+UNKNOWN(null),
+BMP(BmpImagingParameters::new, "bmp", "dib"),
+DCX(PcxImagingParameters::new, "dcx"),
+GIF(GifImagingParameters::new, "gif"),
+ICNS(IcnsImagingParameters::new, "icns"),
+ICO(IcoImagingParameters::new, "ico"),
+JBIG2(null),
+JPEG(JpegImagingParameters::new, "jpg", "jpeg"),
+PAM(PnmImagingParameters::new, "pam"),
+PSD(PsdImagingParameters::new, "psd"),
+PBM(PnmImagingParameters::new, "pbm"),
+PGM(PnmImagingParameters::new, "pgm"),
+PNM(PnmImagingParameters::new, "pnm"),
+PPM(PnmImagingParameters::new, "ppm"),
+PCX(PcxImagingParameters::new, "pcx", "pcc"),
+PNG(PngImagingParameters::new, "png"),
+RGBE(RgbeImagingParameters::new, "rgbe"),
+TGA(null),
+TIFF(TiffImagingParameters::new, "tif", "tiff"),
+WBMP(WbmpImagingParameters::new, "wbmp"),
+XBM(XbmImagingParameters::new, "xbm"),
+XPM(XpmImagingParameters::new, "xpm");
+
+private final String[] extensions;
+
+ImageFormats(Supplier factory, String 
...extensions) {
+this.extensions = extensions;
+}
 
 @Override
 public String getName() {
 return name();
 }
 
 @Override
-public String getExtension() {
-return name();
+public String[] getExtensions() {
+return this.extensions.clone();
+}
+
+@Override
+public String getDefaultExtension() {
+return this.extensions[0];

Review comment:
   `ImageFormats.UNKNOWN.getDefaultExtension()` throws index out of bounds.

##
File path: src/main/java/org/apache/commons/imaging/Imaging.java
##
@@ -16,9 +16,6 @@
  */
 package org.apache.commons.imaging;
 
-import static org.apache.commons.imaging.ImagingConstants.PARAM_KEY_FILENAME;
-import static org.apache.commons.imaging.ImagingConstants.PARAM_KEY_FORMAT;

Review comment:
   Woo hoo!

##
File path: src/main/java/org/apache/commons/imaging/ImageFormat.java
##
@@ -33,6 +34,7 @@
  *
  * @return String extension
  */
-String getExtension();
+String[] getExtensions();

Review comment:
   Use `List` instead of `String[]`? I generally find lists easier 
to work with, especially for streams.

##
File path: src/main/java/org/apache/commons/imaging/ImageFormats.java
##
@@ -16,40 +16,68 @@
  */
 package org.apache.commons.imaging;
 
+import org.apache.commons.imaging.formats.bmp.BmpImagingParameters;
+import org.apache.commons.imaging.formats.gif.GifImagingParameters;
+import org.apache.commons.imaging.formats.icns.IcnsImagingParameters;
+import org.apache.commons.imaging.formats.ico.IcoImagingParameters;
+import org.apache.commons.imaging.formats.jpeg.JpegImagingParameters;
+import org.apache.commons.imaging.formats.pcx.PcxImagingParameters;
+import org.apache.commons.imaging.formats.png.PngImagingParameters;
+import org.apache.commons.imaging.formats.pnm.PnmImagingParameters;
+import org.apa

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-12-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Dec/21 13:11
Start Date: 03/Dec/21 13:11
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-985507050


   Cool! I'll try to take a look at this over the weekend.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 689990)
Time Spent: 15h 20m  (was: 15h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 15h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-12-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 02/Dec/21 09:37
Start Date: 02/Dec/21 09:37
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r760907698



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -898,7 +892,7 @@ public boolean canAcceptType(final ImageFormat type) {
  * @param file An valid file reference.
  * @return If the parser can accept the format, true; otherwise, false.
  */
-protected final boolean canAcceptExtension(final File file) {
+public boolean canAcceptExtension(final File file) {

Review comment:
   Made it public because I created methods in the new internal `Util` 
class. Similar to the already public `canAcceptType(ImageFormat)` of this class.

##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -123,12 +115,18 @@
 new TiffImageParser(),
 new WbmpImageParser(),
 new XbmImageParser(),
-new XpmImageParser(),
+new XpmImageParser()
 // new JBig2ImageParser(),
 // new TgaImageParser(),
-};
+);
 }
 
+/**
+ * Get a default parameters instance for this parser.
+ * @return default parameters instance
+ */
+public abstract T getDefaultParameters();

Review comment:
   Copied from @darkma773r 's PR. By moving it here from the `ImageFormat` 
(i.e. responsible for defining the default parameter is the parser, not the 
format) several generics warnings don't happen anymore.

##
File path: src/main/java/org/apache/commons/imaging/internal/Util.java
##
@@ -0,0 +1,54 @@
+/*
+ * 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.internal;
+
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+import org.apache.commons.imaging.ImageFormat;
+import org.apache.commons.imaging.ImageParser;
+import org.apache.commons.imaging.ImagingParameters;
+
+/**
+ * Internal utilities.
+ *
+ * @since 1.0-alpha3
+ */
+public class Util {
+
+private Util() {}
+
+public static  ImageParser 
getImageParser(ImageFormat format) {
+return getImageParser((parser) -> parser.canAcceptType(format), () -> 
new RuntimeException("Unknown Format: " + format));
+}
+
+public static  ImageParser 
getImageParser(String fileExtension) {
+return getImageParser((parser) -> 
parser.canAcceptExtension(fileExtension), () -> new RuntimeException("Unknown 
Extension: " + fileExtension));
+}
+
+// This generics suppression is as good as the predicate given. If the 
predicate violates a generics design,
+// then there will be an error during runtime.
+@SuppressWarnings("unchecked")
+private static  ImageParser 
getImageParser(Predicate> pred, Supplier supl) {
+return (ImageParser) ImageParser
+.getAllImageParsers()
+.stream()
+.filter((parser) -> pred.test(parser))
+.findFirst()

Review comment:
   This is the only place where we have an issue with the generics used in 
this PR now. The `Predicate` given to this function should return `true` only 
if the parser matches something like a file format, file extension, etc.
   
   Assuming the predicate is correct, there should be no runtime errors for the 
parameters :+1: that's the best we can achieve with Java generics IMO

##
File path: src/main/java/org/apache/commons/imaging/Imaging.java
##
@@ -16,9 +16,6 @@
  */
 package org.apache.commons.imaging;
 
-import static org.apache.commons.imaging.ImagingConstants.PARAM_KEY_FILENAME;
-import static org.apache.commons.imaging.ImagingConstants.PARAM_KEY_FORMAT;

Review comment:
   N.B. no generics warnings being suppr

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-08 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Nov/21 12:10
Start Date: 08/Nov/21 12:10
Worklog Time Spent: 10m 
  Work Description: kinow edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-963088960


   Agreed @darkma773r , +1 on @gwlucastrig suggestion too. Let's review Imaging 
class. Will start thinking on what/how to change too 👍


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 678437)
Time Spent: 15h  (was: 14h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 15h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-08 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Nov/21 12:10
Start Date: 08/Nov/21 12:10
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-963088960


   Agreed @darkma773r , +1 on @gwlucastrig suggestion too. Let's review Imaging 
class. Will start thinking on what/how to change 👍


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 678436)
Time Spent: 14h 50m  (was: 14h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 14h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-08 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Nov/21 12:04
Start Date: 08/Nov/21 12:04
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-963083902


   @kinow
   
   I agree with @gwlucastrig, that we should try to keep the API simple. It 
might be helpful to take a step back and enumerate all of the use cases the API 
should cover and then decide how they should be handled. Below is what I see 
(from my limited perspective) as the main use cases. Please add any I've missed.
   1. The user wants to read/write an image and does not know or care about the 
format.
   2. The user wants to read/write an image and does not know the format but 
wants to apply some format-specific parameters if applicable.
   3. The user wants to read/write an image in a specific format.
   
   For the first use case, I think @gwlucastrig's idea of removing 
format-specific parameters from `Imaging` applies. The caller would use the 
`Imaging` class and then either pass no parameters or pass a very basic 
`ImagingParameters` instance.
   
   For the second use case, I think the responsibility for creating the correct 
parameters object could fall to the user. For example, the user would use 
`Imaging.guessFormat()` to get the format and then use the format-specific 
parser directly to access additional features. The `Imaging` class would not 
play a role after the initial determination of the format.
   
   For the third use case, I think users should use the format-specific parser 
directly. 
   
   So, what I'm picturing basically boils down to this:
   - Do you want to read/write images and only care about the most basic of 
image parameters? Great! Use `Imaging`.
   - Do you want to read/write images in a specific format and access low-level 
format features? Cool. Use the parser for the format.
   
   This approach would remove some of the design headaches we keep running into 
with `Imaging`, where we're trying to allow access to format-specific features 
from generic code. If we can agree on how the API should address these use 
cases then we can move on to deciding how to make the API readable and 
user-friendly.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 678434)
Time Spent: 14h 40m  (was: 14.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 14h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 20:39
Start Date: 05/Nov/21 20:39
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961461586






-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 677798)
Time Spent: 14.5h  (was: 14h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 14.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 20:25
Start Date: 05/Nov/21 20:25
Worklog Time Spent: 10m 
  Work Description: kinow edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961796289


   That is a good point @gwlucastrig , and I have no objections to massaging 
the code of the `Imaging` class. I will spend some time thinking about that, 
and seeing if/when the parameters would be useful or not. Thanks!!! (and you 
have a perspective of user + dev, which is really valuable @gwlucastrig !)


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 677680)
Time Spent: 14h 20m  (was: 14h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 14h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 20:11
Start Date: 05/Nov/21 20:11
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961784862


   My perspective is limited because I am so focused on TIFFs. And I seldom use 
the basic Imaging class (preferring the TIFF-specific parser and write 
classes).   So I am sure I am unaware of a number of valid use cases. 
   
   That being said, I might think that simpler is better.  The Imaging class 
API could be cut back to just include only limited support for parameters.  The 
read-related operations might not even take parameters arguments.  The 
write-related would only take a very basic parameters.  In fact, except for a 
"dots per inch" or "mm per pixel" setting, I can't think of anything that would 
be supported across the majority of write operations.  


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 677579)
Time Spent: 14h 10m  (was: 14h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 14h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 19:50
Start Date: 05/Nov/21 19:50
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961461586






-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 677425)
Time Spent: 14h  (was: 13h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 14h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 19:33
Start Date: 05/Nov/21 19:33
Worklog Time Spent: 10m 
  Work Description: kinow edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961796289


   That is a good point @gwlucastrig , and I have no objections to massaging 
the code of the `Imaging` class. I will spend some time thinking about that, 
and seeing if/when the parameters would be useful or not. Thanks!!! (and you 
have a perspective of user + dev, which is really valuable @gwlucastrig !)


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 677289)
Time Spent: 13h 50m  (was: 13h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 13h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 19:18
Start Date: 05/Nov/21 19:18
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961784862


   My perspective is limited because I am so focused on TIFFs. And I seldom use 
the basic Imaging class (preferring the TIFF-specific parser and write 
classes).   So I am sure I am unaware of a number of valid use cases. 
   
   That being said, I might think that simpler is better.  The Imaging class 
API could be cut back to just include only limited support for parameters.  The 
read-related operations might not even take parameters arguments.  The 
write-related would only take a very basic parameters.  In fact, except for a 
"dots per inch" or "mm per pixel" setting, I can't think of anything that would 
be supported across the majority of write operations.  


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 677170)
Time Spent: 13h 40m  (was: 13.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 13h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 10:57
Start Date: 05/Nov/21 10:57
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961799086


   @darkma773r I've been thinking the types we use in that class, like 
`ImageParser`, `ImagingParameter`, and `ImageFormat`. When we pass the 
arguments to `writeImage`, for example, it includes a `ImageFormat`, and also 
an `ImagingParameters`.
   
   However, when you pass an `ImageFormats.GIF` it's obvious the parameter will 
be of type `GifImagingParameters`. It is also obvious the parser will be the 
`GifImageParser`.
   
   I'm thinking that maybe we could use something like `ImagingParameters` 
and `ImageParser`, eliminating the `ImageFormat`. I think it would be 
possible to have a map of format=>parser, and a method that retrieves the 
parser with the right format. Sorry if it's vague, I will think more about it 
this weekend and see if I can suggest some code to compare with what we have 👍 
   
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 676976)
Time Spent: 13.5h  (was: 13h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 13.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 10:52
Start Date: 05/Nov/21 10:52
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961796289


   That is a good point @gwlucastrig , and I have no objections to massaging 
the code of the `Imaging` class. I will spend some time thinking about that, 
and seeing if/when the parameters would be useful or not. Thanks!!!


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 676972)
Time Spent: 13h 10m  (was: 13h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 13h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 10:52
Start Date: 05/Nov/21 10:52
Worklog Time Spent: 10m 
  Work Description: kinow edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961796289


   That is a good point @gwlucastrig , and I have no objections to massaging 
the code of the `Imaging` class. I will spend some time thinking about that, 
and seeing if/when the parameters would be useful or not. Thanks!!! (and you 
have a perspective of user + dev, which is really valuable @gwlucastrig !)


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 676973)
Time Spent: 13h 20m  (was: 13h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 13h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-05 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 05/Nov/21 10:32
Start Date: 05/Nov/21 10:32
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961784862


   My perspective is limited because I am so focused on TIFFs. And I seldom use 
the basic Imaging class (preferring the TIFF-specific parser and write 
classes).   So I am sure I am unaware of a number of valid use cases. 
   
   That being said, I might think that simpler is better.  The Imaging class 
API could be cut back to just include only limited support for parameters.  The 
read-related operations might not even take parameters arguments.  The 
write-related would only take a very basic parameters.  In fact, except for a 
"dots per inch" or "mm per pixel" setting, I can't think of anything that would 
be supported across the majority of write operations.  


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 676964)
Time Spent: 13h  (was: 12h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 13h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-04 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Nov/21 21:55
Start Date: 04/Nov/21 21:55
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-961461586


   >I just had another thought on this: it strikes me that the main issue with 
the generic ImagerParser format is how to deal 
with format-agnostic code, mainly the utility methods in Imaging. 
   
   Exactly. Were it not for the `Imaging` public methods, we could use the 
generics or any other design without much impact to users. But the current code 
base uses `Imaging` as the main entry point for users in the API (unless users 
want something more complicated, in which case they can use parsers directly.)
   
   >In other words, how do users specify parameters when they don't even know 
what the format is? The current approach is to have users pass in their own 
parameters objects to these utility methods but this gets into the problem of 
what happens when they pass the wrong parameters type.
   
   :+1: you described the problem really well!
   
   >What if we flipped this? Instead of having the users create the parameters 
object, we have the parser create one and then have the user modify it as 
needed in a callback. So, instead of this
   
   Ah, it sounds like a good thing to try! I think this approach would apply 
some inversion of control, or algebraic effects, and could help us solve the 
current impasse.
   
   >Thoughts?
   
   I think it would need a few more changes to allow users to configure the 
correct parameter type? The `Consumer` uses the base type, 
so in this closure the user has only an instance of `ImagingParameters`, and 
would have to cast to the correct type.
   
   I used the last method in `Imaging.java` instead of `getIccProfileBytes` 
(for convenience, to have the `main` method nearby in the IDE :grimacing: ):
   
   ```java
   public static void writeImage(final BufferedImage src, final 
OutputStream os,
   final ImageFormat format, final Consumer 
configurer) throws ImageWriteException,
   IOException {
   final List imageParsers = 
ImageParser.getAllImageParsers();
   ImageParser imageParser = null;
   for (final ImageParser imageParser2 : imageParsers) {
   if (imageParser2.canAcceptType(format)) {
   imageParser = imageParser2;
   break;
   }
   }
   if (imageParser == null) {
   throw new ImageWriteException("Unknown Format: " + format);
   }
   final ImagingParameters params = imageParser.getDefaultParameters();
   configurer.accept(params);
   imageParser.writeImage(src, os, params);
   }
   ```
   
   But the caller code still has issues with the parameter type, I think?
   
   ```java
   public static void main(String[] args) throws Exception {
   Imaging.writeImage(
   (BufferedImage) null,
   (OutputStream) null,
   ImageFormats.TIFF,
   (ImagingParameters p) -> { // if `TiffImagingParameters`: 
Incompatible parameter types in lambda expression: expected ImagingParameters 
but found TiffImagingParameters
   // p is still ImagingParameters, not 
TiffImagingParameters
   p.setFileName("bla.tif");
   });
   }
   ```
   
   Or would you re-write `writeImage` differently, @darkma773r ? 
   
   Thanks!
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 676756)
Time Spent: 12h 50m  (was: 12h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 12h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when t

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Nov/21 01:52
Start Date: 04/Nov/21 01:52
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-959156762


   I just had another thought on this: it strikes me that the main issue with 
the generic `ImagerParser` format is how to deal 
with format-agnostic code, mainly the utility methods in `Imaging`. In other 
words, how do users specify parameters when they don't even know what the 
format is? The current approach is to have users pass in their own parameters 
objects to these utility methods but this gets into the problem of what happens 
when they pass the wrong parameters type. What if we flipped this? Instead of 
having the users create the parameters object, we have the parser create one 
and then have the user modify it as needed in a callback. So, instead of this
   ```
   public static byte[] getICCProfileBytes(final File file, final 
ImagingParameters params) {
// hopefully params is of the correct type!
   }
   ```
   we do this
   ```
   public static byte[] getICCProfileBytes(final File file, final 
Consumer configurer) {
ImageParser parser = ...; // get the parser
return getICCProfileBytes(parser, configurer);
   }
   
   private static  byte[] getICCProfileBytes(final 
ImageParser parser, final Consumer configurer) {
P params = parser.getDefaultParameters();
if (configurer != null) {
// let the caller configure the parameters
configurer.accept(params);
}

// params is known to be the correct type
return parser.getICCProfileBytes(params);
   }
   ```
   Users would then call it like this:
   ```
   Imaging.getICCProfileBytes(file, p -> p.setStrict(true));
   ```
   
   We could also add methods to `ImageParser` that accept consumers like this 
for consistency. That would probably be best.
   
   Thoughts?


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 676032)
Time Spent: 12h 40m  (was: 12.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 12h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Nov/21 01:48
Start Date: 04/Nov/21 01:48
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-958618064


   >>  If the JpegImageParser requires a parameter different than the 
TiffImageParser, I assume we would have to create a new JpegImagingParameter. 
In that case, wouldn't we have to keep the old constructor for backward 
compatibility until a new major release?
   >
   >I'm not totally sure what you mean here. Can you give an example?
   
   Sorry, I wasn't very clear. At the moment we have `JpegImageParser parser = 
new JpegImageParser();`. Internally, the `JpegImageParser` is using a 
`TiffImagingParameters`.
   
   But if we need to add a parameter that is used only by the 
`JpegImageParser`, I think we would want to have a `JpegImagingParameters`. In 
which case I am not sure if we would be able to maintain backward compatibility 
by replacing the `TiffImagingParameters` in the `JpegImageParser`.
   
   >since it makes it it kind of hard to tell what parameters to use when 
creating images of a certain type.
   
   :point_up: this is my main concern. Avoid users having to guess what's the 
parameter that they want to use when parsing a Jpeg, Tiff, Gif, etc. Preferably 
something that their IDE's can assist with, using auto-complete for example.
   
   >One idea for making this readily available in the API would be to add 
convenience factory methods in Imaging for creating instances of each 
parameters type. Ex:
   
   Possibly another design to consider/experiment :-)
   
   >Side note: Is there a reason the JpegImageParser uses TiffImageParameters? 
The two formats are not related, correct? Perhaps we could have a common base 
class for them?
   
   We can probably avoid that. I agree it doesn't make much sense for the 
parameters to have a relationship like that. Currently, 
[`JpegImageParser`](https://github.com/apache/commons-imaging/blob/0ccabc3416cecf25cdec90a522f0912baf19bc58/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java#L751)
 has some code in common with the `TiffImageParser` for parsing EXIF metadata. 
I don't recall 100%, but I believe that's why I implemented everything in the 
`TiffImagingParameters` and, realizing the Jpeg parameters were the same, made 
the parent-child class relantionship.
   
   >Is the idea that it is confusing on what properties are copied over?
   
   Not at all, that part is clear and looks OK. It's with users being able to 
use the wrong parameter class by accident, and realizing only in runtime iff a 
runtime exception is thrown (or in the worst case, no exception is thrown and 
the program behaves in a wrong way; debugging an issue like that can be 
annoying I think).
   
   >I attempted to retain the null parameter functionality. In the 
normalizeParameters method, if a null parameter is passed, a default instance 
is created and returned, allowing downstream code to bypass null checks. mvn 
clean install passes with my current setup. Is there a unit test I missed?
   
   Ah, my bad! Your solution works with the method I was looking at. I wrote 
this one before looking at the method that creates the default parameters :+1: 
   
   I need to find some time to “get in the zone” and try a few things. But it 
would be, mainly, to prevent users being able to use the wrong parameter types 
by accident, and making it so that we can add/remove parameters (deprecating 
what was removed) in the 1.x release series without worrying about backward 
compatibility. If we are able to modify your PR again to accommodate these two 
requirements, I think we would have the perfect solution :-)
   
   Thanks a lot!
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 675987)
Time Spent: 12.5h  (was: 12h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
>

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Nov/21 01:10
Start Date: 04/Nov/21 01:10
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-958597172






-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 675626)
Time Spent: 12h 20m  (was: 12h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 12h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Nov/21 01:06
Start Date: 04/Nov/21 01:06
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-958618064


   >>  If the JpegImageParser requires a parameter different than the 
TiffImageParser, I assume we would have to create a new JpegImagingParameter. 
In that case, wouldn't we have to keep the old constructor for backward 
compatibility until a new major release?
   >
   >I'm not totally sure what you mean here. Can you give an example?
   
   Sorry, I wasn't very clear. At the moment we have `JpegImageParser parser = 
new JpegImageParser();`. Internally, the `JpegImageParser` is using a 
`TiffImagingParameters`.
   
   But if we need to add a parameter that is used only by the 
`JpegImageParser`, I think we would want to have a `JpegImagingParameters`. In 
which case I am not sure if we would be able to maintain backward compatibility 
by replacing the `TiffImagingParameters` in the `JpegImageParser`.
   
   >since it makes it it kind of hard to tell what parameters to use when 
creating images of a certain type.
   
   :point_up: this is my main concern. Avoid users having to guess what's the 
parameter that they want to use when parsing a Jpeg, Tiff, Gif, etc. Preferably 
something that their IDE's can assist with, using auto-complete for example.
   
   >One idea for making this readily available in the API would be to add 
convenience factory methods in Imaging for creating instances of each 
parameters type. Ex:
   
   Possibly another design to consider/experiment :-)
   
   >Side note: Is there a reason the JpegImageParser uses TiffImageParameters? 
The two formats are not related, correct? Perhaps we could have a common base 
class for them?
   
   We can probably avoid that. I agree it doesn't make much sense for the 
parameters to have a relationship like that. Currently, 
[`JpegImageParser`](https://github.com/apache/commons-imaging/blob/0ccabc3416cecf25cdec90a522f0912baf19bc58/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java#L751)
 has some code in common with the `TiffImageParser` for parsing EXIF metadata. 
I don't recall 100%, but I believe that's why I implemented everything in the 
`TiffImagingParameters` and, realizing the Jpeg parameters were the same, made 
the parent-child class relantionship.
   
   >Is the idea that it is confusing on what properties are copied over?
   
   Not at all, that part is clear and looks OK. It's with users being able to 
use the wrong parameter class by accident, and realizing only in runtime iff a 
runtime exception is thrown (or in the worst case, no exception is thrown and 
the program behaves in a wrong way; debugging an issue like that can be 
annoying I think).
   
   >I attempted to retain the null parameter functionality. In the 
normalizeParameters method, if a null parameter is passed, a default instance 
is created and returned, allowing downstream code to bypass null checks. mvn 
clean install passes with my current setup. Is there a unit test I missed?
   
   Ah, my bad! Your solution works with the method I was looking at. I wrote 
this one before looking at the method that creates the default parameters :+1: 
   
   I need to find some time to “get in the zone” and try a few things. But it 
would be, mainly, to prevent users being able to use the wrong parameter types 
by accident, and making it so that we can add/remove parameters (deprecating 
what was removed) in the 1.x release series without worrying about backward 
compatibility. If we are able to modify your PR again to accommodate these two 
requirements, I think we would have the perfect solution :-)
   
   Thanks a lot!
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 675602)
Time Spent: 12h 10m  (was: 12h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
>  

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Nov/21 00:13
Start Date: 04/Nov/21 00:13
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-958597172






-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 675118)
Time Spent: 12h  (was: 11h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 12h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Nov/21 00:10
Start Date: 04/Nov/21 00:10
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-958618064


   >>  If the JpegImageParser requires a parameter different than the 
TiffImageParser, I assume we would have to create a new JpegImagingParameter. 
In that case, wouldn't we have to keep the old constructor for backward 
compatibility until a new major release?
   >
   >I'm not totally sure what you mean here. Can you give an example?
   
   Sorry, I wasn't very clear. At the moment we have `JpegImageParser parser = 
new JpegImageParser();`. Internally, the `JpegImageParser` is using a 
`TiffImagingParameters`.
   
   But if we need to add a parameter that is used only by the 
`JpegImageParser`, I think we would want to have a `JpegImagingParameters`. In 
which case I am not sure if we would be able to maintain backward compatibility 
by replacing the `TiffImagingParameters` in the `JpegImageParser`.
   
   >since it makes it it kind of hard to tell what parameters to use when 
creating images of a certain type.
   
   :point_up: this is my main concern. Avoid users having to guess what's the 
parameter that they want to use when parsing a Jpeg, Tiff, Gif, etc. Preferably 
something that their IDE's can assist with, using auto-complete for example.
   
   >One idea for making this readily available in the API would be to add 
convenience factory methods in Imaging for creating instances of each 
parameters type. Ex:
   
   Possibly another design to consider/experiment :-)
   
   >Side note: Is there a reason the JpegImageParser uses TiffImageParameters? 
The two formats are not related, correct? Perhaps we could have a common base 
class for them?
   
   We can probably avoid that. I agree it doesn't make much sense for the 
parameters to have a relationship like that. Currently, 
[`JpegImageParser`](https://github.com/apache/commons-imaging/blob/0ccabc3416cecf25cdec90a522f0912baf19bc58/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java#L751)
 has some code in common with the `TiffImageParser` for parsing EXIF metadata. 
I don't recall 100%, but I believe that's why I implemented everything in the 
`TiffImagingParameters` and, realizing the Jpeg parameters were the same, made 
the parent-child class relantionship.
   
   >Is the idea that it is confusing on what properties are copied over?
   
   Not at all, that part is clear and looks OK. It's with users being able to 
use the wrong parameter class by accident, and realizing only in runtime iff a 
runtime exception is thrown (or in the worst case, no exception is thrown and 
the program behaves in a wrong way; debugging an issue like that can be 
annoying I think).
   
   >I attempted to retain the null parameter functionality. In the 
normalizeParameters method, if a null parameter is passed, a default instance 
is created and returned, allowing downstream code to bypass null checks. mvn 
clean install passes with my current setup. Is there a unit test I missed?
   
   Ah, my bad! Your solution works with the method I was looking at. I wrote 
this one before looking at the method that creates the default parameters :+1: 
   
   I need to find some time to “get in the zone” and try a few things. But it 
would be, mainly, to prevent users being able to use the wrong parameter types 
by accident, and making it so that we can add/remove parameters (deprecating 
what was removed) in the 1.x release series without worrying about backward 
compatibility. If we are able to modify your PR again to accommodate these two 
requirements, I think we would have the perfect solution :-)
   
   Thanks a lot!
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 675091)
Time Spent: 11h 50m  (was: 11h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-03 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Nov/21 14:03
Start Date: 03/Nov/21 14:03
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-959156762


   I just had another thought on this: it strikes me that the main issue with 
the generic `ImagerParser` format is how to deal 
with format-agnostic code, mainly the utility methods in `Imaging`. In other 
words, how do users specify parameters when they don't even know what the 
format is? The current approach is to have users pass in their own parameters 
objects to these utility methods but this gets into the problem of what happens 
when they pass the wrong parameters type. What if we flipped this? Instead of 
having the users create the parameters object, we have the parser create one 
and then have the user modify it as needed in a callback. So, instead of this
   ```
   public static byte[] getICCProfileBytes(final File file, final 
ImagingParameters params) {
// hopefully params is of the correct type!
   }
   ```
   we do this
   ```
   public static byte[] getICCProfileBytes(final File file, final 
Consumer configurer) {
ImageParser parser = ...; // get the parser
return getICCProfileBytes(parser, configurer);
   }
   
   private static  byte[] getICCProfileBytes(final 
ImageParser parser, final Consumer configurer) {
P params = parser.getDefaultParameters();
if (configurer != null) {
// let the caller configure the parameters
configurer.accept(params);
}

// params is known to be the correct type
return parser.getICCProfileBytes(params);
   }
   ```
   Users would then call it like this:
   ```
   Imaging.getICCProfileBytes(file, p -> p.setStrict(true));
   ```
   
   We could also add methods to `ImageParser` that accept consumers like this 
for consistency. That would probably be best.
   
   Thoughts?


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 674627)
Time Spent: 11h 40m  (was: 11.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 11h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Nov/21 03:08
Start Date: 03/Nov/21 03:08
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-958618064


   >>  If the JpegImageParser requires a parameter different than the 
TiffImageParser, I assume we would have to create a new JpegImagingParameter. 
In that case, wouldn't we have to keep the old constructor for backward 
compatibility until a new major release?
   >
   >I'm not totally sure what you mean here. Can you give an example?
   
   Sorry, I wasn't very clear. At the moment we have `JpegImageParser parser = 
new JpegImageParser();`. Internally, the `JpegImageParser` is using a 
`TiffImagingParameters`.
   
   But if we need to add a parameter that is used only by the 
`JpegImageParser`, I think we would want to have a `JpegImagingParameters`. In 
which case I am not sure if we would be able to maintain backward compatibility 
by replacing the `TiffImagingParameters` in the `JpegImageParser`.
   
   >since it makes it it kind of hard to tell what parameters to use when 
creating images of a certain type.
   
   :point_up: this is my main concern. Avoid users having to guess what's the 
parameter that they want to use when parsing a Jpeg, Tiff, Gif, etc. Preferably 
something that their IDE's can assist with, using auto-complete for example.
   
   >One idea for making this readily available in the API would be to add 
convenience factory methods in Imaging for creating instances of each 
parameters type. Ex:
   
   Possibly another design to consider/experiment :-)
   
   >Side note: Is there a reason the JpegImageParser uses TiffImageParameters? 
The two formats are not related, correct? Perhaps we could have a common base 
class for them?
   
   We can probably avoid that. I agree it doesn't make much sense for the 
parameters to have a relationship like that. Currently, 
[`JpegImageParser`](https://github.com/apache/commons-imaging/blob/0ccabc3416cecf25cdec90a522f0912baf19bc58/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java#L751)
 has some code in common with the `TiffImageParser` for parsing EXIF metadata. 
I don't recall 100%, but I believe that's why I implemented everything in the 
`TiffImagingParameters` and, realizing the Jpeg parameters were the same, made 
the parent-child class relantionship.
   
   >Is the idea that it is confusing on what properties are copied over?
   
   Not at all, that part is clear and looks OK. It's with users being able to 
use the wrong parameter class by accident, and realizing only in runtime iff a 
runtime exception is thrown (or in the worst case, no exception is thrown and 
the program behaves in a wrong way; debugging an issue like that can be 
annoying I think).
   
   >I attempted to retain the null parameter functionality. In the 
normalizeParameters method, if a null parameter is passed, a default instance 
is created and returned, allowing downstream code to bypass null checks. mvn 
clean install passes with my current setup. Is there a unit test I missed?
   
   Ah, my bad! Your solution works with the method I was looking at. I wrote 
this one before looking at the method that creates the default parameters :+1: 
   
   I need to find some time to “get in the zone” and try a few things. But it 
would be, mainly, to prevent users being able to use the wrong parameter types 
by accident, and making it so that we can add/remove parameters (deprecating 
what was removed) in the 1.x release series without worrying about backward 
compatibility. If we are able to modify your PR again to accommodate these two 
requirements, I think we would have the perfect solution :-)
   
   Thanks a lot!
   Bruno


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 674354)
Time Spent: 11.5h  (was: 11h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
>

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-02 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 03/Nov/21 02:03
Start Date: 03/Nov/21 02:03
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-958597172


   @kinow 
   
   > If the JpegImageParser requires a parameter different than the 
TiffImageParser, I assume we would have to create a new JpegImagingParameter. 
In that case, wouldn't we have to keep the old constructor for backward 
compatibility until a new major release?
   
   I'm not totally sure what you mean here. Can you give an example? 
   
   On a related note, in my merge request, I removed all of the parameter 
classes that did not actually have any of their own properties (such as 
JpegImageParameters). I'm not sure if this is a great idea, though, since it 
makes it it kind of hard to tell what parameters to use when creating images of 
a certain type. If might be better to add them back just for the convenience of 
not having to look in the documentation to find what parameters class to use. 
For example, if you are creating a JPEG, you automatically know that you need a 
JpegImageParameters; BMP implies BmpImageParameters, etc.
   
   One idea for making this readily available in the API would be to add 
convenience factory methods in Imaging for creating instances of each 
parameters type. Ex:
   ```
   public static BmpImageParameters bmpParameters() { return new 
BmpImageParameters(); }
   public static TiffImageParameters tiffParameters() { return new 
TiffImageParameters(); }
   ```
   This way, users would be able to find the parameters class they want by 
looking at a single class. The methods would return the specific 
ImageParameters subclass so users could immediately access all of the available 
properties.
   
   Side note: Is there a reason the JpegImageParser uses TiffImageParameters? 
The two formats are not related, correct? Perhaps we could have a common base 
class for them?
   
   > I think it would be best if cases like this were not allowed 
PcxImagingParameters parser = new PcxImagingParameters(new 
TiffImagingParameters()); // no error in compile or runtime
   
   Is the idea that it is confusing on what properties are copied over? My 
thought is that the copy constructor copies over as many fields as it can and 
ignores the rest. For example, say you are writing an image out in multiple 
formats. You could create a very specific parameter instance and then use the 
copy constructors to copy relevant fields for the other formats.
   
   ```
   TiffImageParameters tiffParams = new TiffImageParameters();
   // populate params...
   
   // create images
   Imaging.writeImage(src, fileA, ImageFormats.TIFF, tiffParams);
   Imaging.writeImage(src, fileB, ImageFormats.BMP, new 
BmpImageParameters(tiffParams));
   Imaging.writeImage(src, fileC, ImageFormats.PNG, new 
PngImageParameters(tiffParams));
   ```
   
   > I think you removed the option to allow null parameters in the 
Imaging#writeImage method (and other methods). I thought about doing that too, 
that would remove one generic suppress I think, but there are unit tests and 
examples. The API has allowed it since Sanselan, so not too sure about 
enforcing parameters to be non-null now.
   
   I attempted to retain the null parameter functionality. In the 
`normalizeParameters` method, if a null parameter is passed, a default instance 
is created and returned, allowing downstream code to bypass null checks. `mvn 
clean install` passes with my current setup. Is there a unit test I missed?
   
   > I liked the error in this one new PngImageParser().writeImage(null, null, 
new TiffImagingParameters());, which gives java.lang.IllegalArgumentException: 
Invalid imaging parameters: expected type...
   
   Thanks! :-)


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 674306)
Time Spent: 11h 20m  (was: 11h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
> 

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-11-01 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 01/Nov/21 09:44
Start Date: 01/Nov/21 09:44
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-956081611


   @darkma773r 
   
   Thanks a lot for creating that pull request. Really clever the intermediate 
`GenericImageParser`. I liked it and might use it later! :+1: 
   
   A few questions/notes, feel free to point if any of what I say is off the 
mark.
   
   1. If the `JpegImageParser` requires a parameter different than the 
`TiffImageParser`, I assume we would have to create a new 
`JpegImagingParameter`. In that case, wouldn't we have to keep the old 
constructor for backward compatibility until a new major release?
   2. I think it would be best if cases like this were not allowed 
`PcxImagingParameters parser = new PcxImagingParameters(new 
TiffImagingParameters()); // no error in compile or runtime`
   3. I think you removed the option to allow `null` parameters in the 
`Imaging#writeImage` method (and other methods). I thought about doing that 
too, that would remove one generic suppress I think, but there are unit tests 
and examples. The API has allowed it since Sanselan, so not too sure about 
enforcing parameters to be non-null now.
   4. I liked the error in this one `new PngImageParser().writeImage(null, 
null, new TiffImagingParameters());`, which gives 
`java.lang.IllegalArgumentException: Invalid imaging parameters: expected 
type...`
   
   Your design really solves the generics problems, so I will take another look 
later and see if I find a middle way. See what you think about the `null` 
parameters, and allowing the empty parameters types for `Jpeg` and other 
parsers, or about the other notes @darkma773r :+1: 
   
   Thanks heaps!
   
   ```java
   Imaging.writeImage((BufferedImage) null, (OutputStream) null, 
ImageFormats.GIF, new TiffImagingParameters());
   // java.lang.IllegalArgumentException: Invalid imaging parameters: expected 
type org.apache.commons.imaging.common.XmpImagingParameters or a super class 
but was org.apache.commons.imaging.formats.tiff.TiffImagingParameters :+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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 672593)
Time Spent: 11h 10m  (was: 11h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 11h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-10-30 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 30/Oct/21 12:05
Start Date: 30/Oct/21 12:05
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-955198434


   Thanks a lot @darkma773r !! Will take a look on it.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 672340)
Time Spent: 11h  (was: 10h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 11h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-10-30 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 30/Oct/21 11:54
Start Date: 30/Oct/21 11:54
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-955197158


   I just made a merge request on this branch in your repo, @kinow: 
https://github.com/kinow/commons-imaging/pull/36. Let me know what you think.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 672337)
Time Spent: 10h 50m  (was: 10h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 10h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-10-28 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 28/Oct/21 11:20
Start Date: 28/Oct/21 11:20
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-953750338


   No worries @darkma773r , thanks for having another look at this one!


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 671374)
Time Spent: 10h 40m  (was: 10.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 10h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-10-28 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 28/Oct/21 11:10
Start Date: 28/Oct/21 11:10
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-953743996


   Hello again. Apologies for my silence here. I've been meaning to revisit 
this but just haven't gotten to it. I'll try to spend some time with this over 
the next several days and see if I can come up with something. I feel like we 
are very close.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 671370)
Time Spent: 10.5h  (was: 10h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 10.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-10-24 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 25/Oct/21 02:02
Start Date: 25/Oct/21 02:02
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-950461037


   Hi @gwlucastrig we just need to sort out if the API needs to be redesigned 
due to the generics suppressions or if that's something we can consider a 1.1 
or 2.0 improvement.
   
   I'm inclined to just go with this design - if no other options are presented 
with consensus - and then rethink later in a 2.0 version if needed.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 669342)
Time Spent: 10h 20m  (was: 10h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 10h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-10-24 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 24/Oct/21 22:32
Start Date: 24/Oct/21 22:32
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-950406616


   For what it's worth, I think that your proposed changes will be a
   significant improvement to the API design.
   
   Let me know if you need help.
   
   On Sat, Oct 23, 2021 at 7:09 AM Bruno P. Kinoshita ***@***.***>
   wrote:
   
   > Triaged issues today, and I think this is the last issue pending for 1.0
   > release. The others can still be fixed in 1.0.1, or 1.1.
   >
   > —
   > You are receiving this because you were mentioned.
   > Reply to this email directly, view it on GitHub
   > 
,
   > or unsubscribe
   > 

   > .
   > Triage notifications on the go with GitHub Mobile for iOS
   > 

   > or Android
   > 
.
   >
   >
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 669331)
Time Spent: 10h 10m  (was: 10h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 10h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-10-23 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 23/Oct/21 11:09
Start Date: 23/Oct/21 11:09
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-950136340


   Triaged issues today, and I think this is the last issue pending for 1.0 
release. The others can still be fixed in 1.0.1, or 1.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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 669181)
Time Spent: 10h  (was: 9h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 10h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-09-14 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 14/Sep/21 10:23
Start Date: 14/Sep/21 10:23
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-919020286


   I wonder whether we might be able to use Reflection and move the static 
resolveParameters() method into the base class so that it only appears once. 
resolveParameters would take a class as an additional argument. That approach 
might let us get rid of the two constructors (copy and no-argument) which I 
also saw as error-prone.
   
   I'll have to review Java Generics a bit.  I almost never use them beyond the 
implementations supplied by the Java API.  Perhaps in this case they can be 
applied to simplify our problem.
   
   Also, I think my idea sort of falls apart because the TiffImagingParameters 
does not derive directly from ImagingParameters, but that there is an 
intermediate class:  TiffImagingParameters extends XmpImagingParameters.


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 650478)
Time Spent: 9h 50m  (was: 9h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 9h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-09-13 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 14/Sep/21 03:40
Start Date: 14/Sep/21 03:40
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-918771649


   Hi @gwlucastrig 
   
   Thanks for the detailed example. The only part of the implementation that 
bothers me is the static method.
   
   >Finally, each parameters class would implement a static method:
   
   That might become tedious to maintain that code, and also error-prone. Of 
course generics can also be error-prone, and are not too simple to maintain.
   
   If only we had a way to combine; make so that users can easily write code 
using auto-complete, IDE, etc, in an intuitive way, and in a way that we don't 
have any risks in our side (or very low risk of bugs/hard to maintain 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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 650333)
Time Spent: 9h 40m  (was: 9.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 9h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-09-13 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 14/Sep/21 03:16
Start Date: 14/Sep/21 03:16
Worklog Time Spent: 10m 
  Work Description: gwlucastrig edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-918761710


   I saw the note you posted on the Commons mailing list about the design of 
this.  If you're still looking for ideas for alternate approaches, maybe this 
will help.  I'm wondering if just a simple brute-force approach might do the 
trick.  So I will throw out a wild idea (which I'd be the first to admit I have 
not thought through thoroughly).
   
   We have a number of issues:
   
   1. Handle cases where applications pass in null imaging parameters (just use 
defaults)
   2. Handle cases where applications pass in an instance of the generic 
ImagingParameters base class.
   3. Handle cases where applications pass in an instance of the subject-matter 
imaging parameters (i.e. TiffImagingParameters, PngImagingParameters, etc.).
   4. Handle cases where applications pass in the wrong thing.
   
   ```
   TestStuff testStuff = new TestStuff();   // works on TIFFs (for example)
   testStuff.aTypicalMethod(null);
   testStuff.aTypicalMethod(imgParams);
   testStuff.aTypicalMethod(tiffParams);
   testStuff.aTypicalMethod(pngParams);  // throws exception
   ```
   
   And we'd like to make the contents of "aTypicalMethod" be pretty compact.  
In this case, using TiffImagingParameters as an example, what if 
TiffImagingParameters (and all its brothers and sisters) had a static method 
called resolveParameters(ImagingParameters) that worked like:
   
   ```
 void aTypicalMethod(ImagingParameters imagingParameters) {
   TiffImagingParameters params  = 
TiffImagingParameters.resolveParameters(imagingParameters);
// now do some work using the parameters
 }
   ```
   
   **How we make this work**
   
   The base class would define two constructors. A no-argument constructor and 
a "copy constructor".
   ```
 public ImagingParameters(){
  }
  
 public ImagingParameters(ImagingParameters source) {
   this.bufferedImageFactory = source.bufferedImageFactory;
   this.fileName = source.fileName;
   this.pixelDensity = source.pixelDensity;
   this.strict = source.strict;
 }
   ```
   
   Subject-matter specific parameters classes would implement compatible 
constructors:
   ```
 public TiffImagingParameters(){
 }
 public TiffImagingParameters(ImagingParameters imagingParameters){
   super(imagingParameters);
 }
   ```
   
   Finally, each parameters class would implement a static method:
   
   ```
 static public TiffImagingParameters resolveParameters(ImagingParameters 
imagingParameters) {
   TiffImagingParameters params;
   if (imagingParameters == null) {
 return new TiffImagingParameters();
   } else if (imagingParameters instanceof TiffImagingParameters) {
 return  (TiffImagingParameters) imagingParameters;
   } else if (ImagingParameters.class.equals(imagingParameters.getClass())) 
{
 // the specified class is the generic, base class.
 // so just copy it's content into a new TiffImagingParameters instance
return new TiffImagingParameters(imagingParameters);
   } else {
 // In this case, the calling application gave us an instance of an
 // incompatible parameters class.  
 throw new IllegalArgumentException(
   "Invalid imaging parameters class " 
 + imagingParameters.getClass().getSimpleName());
   }
 }
   ```

   
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 650331)
Time Spent: 9.5h  (was: 9h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 9.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-09-13 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 14/Sep/21 03:15
Start Date: 14/Sep/21 03:15
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-918761710


   I saw the note you posted on the Commons mailing list about the design of 
this.  I'm wondering if just a simple brute-force approach might do the trick.  
So I will throw out a wild idea (which I'd be the first to admit I have not 
thought through thoroughly).
   
   We have a number of issues:
   
   1. Handle cases where applications pass in null imaging parameters (just use 
defaults)
   2. Handle cases where applications pass in an instance of the generic 
ImagingParameters base class.
   3. Handle cases where applications pass in an instance of the subject-matter 
imaging parameters (i.e. TiffImagingParameters, PngImagingParameters, etc.).
   4. Handle cases where applications pass in the wrong thing.
   
   ```
   TestStuff testStuff = new TestStuff();   // works on TIFFs (for example)
   testStuff.aTypicalMethod(null);
   testStuff.aTypicalMethod(imgParams);
   testStuff.aTypicalMethod(tiffParams);
   testStuff.aTypicalMethod(pngParams);  // throws exception
   ```
   
   And we'd like to make the contents of "aTypicalMethod" be pretty compact.  
In this case, using TiffImagingParameters as an example, what if 
TiffImagingParameters (and all its brothers and sisters) had a static method 
called resolveParameters(ImagingParameters) that worked like:
   
   ```
 void aTypicalMethod(ImagingParameters imagingParameters) {
   TiffImagingParameters params  = 
TiffImagingParameters.resolveParameters(imagingParameters);
// now do some work using the parameters
 }
   ```
   
   **How we make this work**
   
   The base class would define two constructors. A no-argument constructor and 
a "copy constructor".
   ```
 public ImagingParameters(){
  }
  
 public ImagingParameters(ImagingParameters source) {
   this.bufferedImageFactory = source.bufferedImageFactory;
   this.fileName = source.fileName;
   this.pixelDensity = source.pixelDensity;
   this.strict = source.strict;
 }
   ```
   
   Subject-matter specific parameters classes would implement compatible 
constructors:
   ```
 public TiffImagingParameters(){
 }
 public TiffImagingParameters(ImagingParameters imagingParameters){
   super(imagingParameters);
 }
   ```
   
   Finally, each parameters class would implement a static method:
   
   ```
 static public TiffImagingParameters resolveParameters(ImagingParameters 
imagingParameters) {
   TiffImagingParameters params;
   if (imagingParameters == null) {
 return new TiffImagingParameters();
   } else if (imagingParameters instanceof TiffImagingParameters) {
 return  (TiffImagingParameters) imagingParameters;
   } else if (ImagingParameters.class.equals(imagingParameters.getClass())) 
{
 // the specified class is the generic, base class.
 // so just copy it's content into a new TiffImagingParameters instance
return new TiffImagingParameters(imagingParameters);
   } else {
 // In this case, the calling application gave us an instance of an
 // incompatible parameters class.  
 throw new IllegalArgumentException(
   "Invalid imaging parameters class " 
 + imagingParameters.getClass().getSimpleName());
   }
 }
   ```

   
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 650329)
Time Spent: 9h 20m  (was: 9h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 9h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are us

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-09-07 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 08/Sep/21 05:30
Start Date: 08/Sep/21 05:30
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-914929304


   Just wrote an e-mail to commons-dev mailing list about the generics issue. 
Let's wait and see if there's any feedback :+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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 647745)
Time Spent: 9h 10m  (was: 9h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 9h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-09-04 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 04/Sep/21 13:23
Start Date: 04/Sep/21 13:23
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/42656656/badge)](https://coveralls.io/builds/42656656)
   
   Coverage decreased (-0.2%) to 76.512% when pulling 
**f136ca85bf930652f7677646548284f871dd7be8 on kinow:IMAGING-159-1** into 
**32e1a3b839eb75b38c47531cb2dd6e0012bb3bf5 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 646602)
Time Spent: 9h  (was: 8h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 9h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-08-01 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 02/Aug/21 04:07
Start Date: 02/Aug/21 04:07
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41817506/badge)](https://coveralls.io/builds/41817506)
   
   Coverage decreased (-0.2%) to 76.512% when pulling 
**f91923a6ebd29679b438bcee9a0ba9e83eb463a9 on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 632142)
Time Spent: 8h 50m  (was: 8h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 8h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-08-01 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 01/Aug/21 11:51
Start Date: 01/Aug/21 11:51
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r680499709



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   A couple more thoughts here: 
   - I like the idea of having the TIFF and JPEG parameters extend a common 
ancestor if possible. That seems like a more maintainable solution. With the 
current hierarchy, if a property needed to be added to the TIFF parameters, it 
would also be added to the JPEG one, regardless of whether or not it applied to 
that format.
   - With the removal of the `imageFormat` property, we could completely remove 
all of the `ImagingParameters` subclasses that do not add any properties, such 
as `BmpImagingParameters`. They do not seem to add much value anymore and could 
easily be added later if needed.




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 632056)
Time Spent: 8h 40m  (was: 8.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 8h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-29 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 29/Jul/21 19:51
Start Date: 29/Jul/21 19:51
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r679442463



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   Good point @gwlucastrig . I will have a look to remember why I extended 
the tiff class.
   
   As for the generics, maybe we can find a compromise between our two options, 
even if it requires further changes (e.g. rethink the Imaging class for 
example). Or maybe after reviewing this jpeg - tiff parent relationship we may 
simplify this code more and have some other ideas.
   Thanks!!!




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 631314)
Time Spent: 8.5h  (was: 8h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 8.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-29 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 29/Jul/21 19:34
Start Date: 29/Jul/21 19:34
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r679432456



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   Well, I am thinking back to my reaction when Java 1.5 first introduced 
generics.  My first thought was "what a good idea".  My second thought was "of 
all the mistakes I have made coding in Java (and there are a lot of them), I 
don't think I ever tried to store the wrong kind of object in a collection".   
My point here is that we need to simplify things for the user as much as 
possible, but if our own code starts to get too complicated we might be going 
down the wrong road.  Also, I wonder why JpegImagingParameters should extend 
TiffImagingParameters. The TIFF format has MANY Tiff-unique elements (support 
for old fashioned FAX parameters, Photogrammetric Interpreters, odd-duck 
compression standards).  I would think that if there were any overlap between 
the two package branches at all, perhaps JpegImagingParameters and 
TiffImagingParameters might have a common ancestor.   Of course, I have been so 
completely focused on TIFF that I haven't really studied the JPEG package. So I 
am not sure how it is organized.
   





-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 631299)
Time Spent: 8h 20m  (was: 8h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 8h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from 

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-28 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 29/Jul/21 06:31
Start Date: 29/Jul/21 06:31
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41740806/badge)](https://coveralls.io/builds/41740806)
   
   Coverage decreased (-0.2%) to 76.543% when pulling 
**0c2ca31b761d95f86c4a58a76026aea930116f12 on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 631012)
Time Spent: 8h 10m  (was: 8h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 8h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-28 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 29/Jul/21 05:46
Start Date: 29/Jul/21 05:46
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r678842742



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   >I'm also leaning toward the "just let it go option" for users that pass 
format-specific parameters to parsers of the wrong format type. In my mind, any 
format-specific parameters that do not apply should just be ignored.
   
   Yeah, I realize that this would be simpler for us to maintain, but I still 
think this could lead to problems to users. There certain formats that people 
may be confused about which parameter class to use.
   
   For example, someone could try the TIFF for JPEG, or vice-versa. The 
`TiffImagingParameters` extends `XmpImagingParameters`. And the 
`JpegImagingParameters` extends the `TiffImagingParameters`. So you could have 
code using a Tiff parser with the `JpegImagingParameters` that works fine. 
Until we - for instance - override a property like compression in the JPEG 
parameter. That could break the code of the user, and would require some 
debugging to understand why that started happening.
   
   If it were not for the `Imaging.java` file, I think we wouldn't have any 
problems with the generics and the current approach in this PR 
:disappointed_relieved:  Maybe we should consult with others in the mailing 
list?
   
   >Side note: @kinow, I'm looking at the ImagingParameters class and I can't 
find any usages of the getImageFormat() method elsewhere in the code. Is that 
method used anywhere?
   
   Ah! It's not! Brilliant catch @darkma773r ! The parsers are using the format 
to write/read. And a parser knows its own format. No need to have it in the 
parameters used in the parser. Thanks a lot for finding this one @darkma773r , 
less one new public API that would need updating later on :+1: 
   
   Removing it.




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 631003)
Time Spent: 8h  (was: 7h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 8h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-28 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 29/Jul/21 05:46
Start Date: 29/Jul/21 05:46
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r678842742



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   >I'm also leaning toward the "just let it go option" for users that pass 
format-specific parameters to parsers of the wrong format type. In my mind, any 
format-specific parameters that do not apply should just be ignored.
   
   Yeah, I realize that this would be simpler for us to maintain, but I still 
think this could lead to problems to users. There certain formats that people 
may be confused about which parameter class to use.
   
   For example, someone could try the TIFF for JPEG, or vice-versa. The 
`TiffImagingParameters` extends `XmpImagingParameters`. And the 
`JpegImagingParameters` extends the `TiffImagingParameters`. So you could have 
code using a Tiff parser with the `JpegImagingParameters` that works fine. 
Until we - for instance - override a property like compression in the JPEG 
parameter. That could break the code of the user, and would require some 
debugging to understand why that started happening.
   
   Maybe we should consult with others in the mailing list?
   
   >Side note: @kinow, I'm looking at the ImagingParameters class and I can't 
find any usages of the getImageFormat() method elsewhere in the code. Is that 
method used anywhere?
   
   Ah! It's not! Brilliant catch @darkma773r ! The parsers are using the format 
to write/read. And a parser knows its own format. No need to have it in the 
parameters used in the parser. Thanks a lot for finding this one @darkma773r , 
less one new public API that would need updating later on :+1: 
   
   Removing it.




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 631002)
Time Spent: 7h 50m  (was: 7h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 7h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-20 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 21/Jul/21 03:00
Start Date: 21/Jul/21 03:00
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r673625407



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   @gwlucastrig, your approach is almost exactly like the one I was going 
to suggest :-)
   - Have `ImageParser` and other classes accept `ImagingParameters` directly.
   - Add format-specific parameter overloads of these methods as needed,
   - Have the general methods either cast the general `ImagingParameters` to 
the format-specific ones or use a copy constructor to extract relevant fields 
while leaving others as defaults.
   
   > I'm leaning to the "just let it go option", but here's one way that the 
run-time checking could be accomplished.
   
   I'm also leaning toward the "just let it go option" for users that pass 
format-specific parameters to parsers of the wrong format type. In my mind, any 
format-specific parameters that do not apply should just be ignored. I'm 
guessing this was the case when the API used a `Map` to pass parameters so we 
shouldn't be losing anything. I would also not expect a method that accepts an 
`ImagingParameters` argument to succeed if I pass one parameter subclass but 
not another one. 
   
   Side note: @kinow, I'm looking at the `ImagingParameters` class and I can't 
find any usages of the `getImageFormat()` method elsewhere in the code. Is that 
method used anywhere?
   




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 625873)
Time Spent: 7h 40m  (was: 7.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 7h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> T

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-20 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 20/Jul/21 21:03
Start Date: 20/Jul/21 21:03
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r673491489



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   Hi @gwlucastrig 
   
   An approach similar to what we are trying here, thanks for sharing! 
   
   >This would compile just fine. However, betaParameters would contain 
information that was irrelevant to the alpha parser. It would probably be a 
case where the programmer made a mistake. The program would probably run, but 
it might not do quite what the developer hoped. Some debugging would be 
necessary. How could we help this case? 
   
   I think we have reached the same point here. While both our approaches lead 
to no generics, the cost is accepting compilation and having to do some runtime 
checking, though not perfect.
   
   >Maybe forget the whole bit about the copy constructor for AlphaParameters. 
I think most classes would just do the branching approach and only the guys who 
needed to do something special would use the copy-constructor approach.
   
   My current experiment is not going anywhere, so I'll `git reset --hard` and 
start testing yours with the copy constructor.




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 625803)
Time Spent: 7.5h  (was: 7h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 7.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-20 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 20/Jul/21 13:16
Start Date: 20/Jul/21 13:16
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r673100545



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   Here's an idea for a plan (or at least 12 percent of an plan):
   
   In the package example.common, we have the class ExampleParameters and the 
interface ExampleParser
   
   ```
   public class ExampleParameters {
   public int test;
   }
   public interface ExampleParser {
   public void parse(ExampleParameters paramaters);
   }
   ```
   
   There are multiple implementing format packages.  In package 
example.format.alpha, we have
   
   ```
   public class AlphaParameters extends ExampleParameters {
   int mess;
   /**
* A copy constructor
* @param source 
*/
   AlphaParameters(ExampleParameters source){
   this.mess =source.test;
   }
   }
   
   public class AlphaParser implements ExampleParser {
   @Override
   public void parse(ExampleParameters parameters) {
 AlphaParameters alphaParameters;
 if(parameters instanceof AlphaParameters){
  alphaParameters = (AlphaParameters)parameters;
 }else{
  alphaParameters = new AlphaParameters(parameters);
}
 parse(alphaParameters);
   }
   
   public void parse(AlphaParameters parameters){
   // do the work
   }
   }
   
   ```
   
   My thinking is that most applications that have format-specific parameters, 
will call their parser class directly and pass in the specific class that goes 
with it (in this example, AlphaParameter... in real life TiffImagingParameters, 
etc.).   Even those that passed in a generic would experience a small overhead 
for the downcast or the copy constructor...  Those application that are use the 
high-level ImageParser class (which determines format and branches based on 
format type) would pass in an instance of the base class ExampleParameters.  
After all, it's only a small performance hit and if they really have 
format-specific needs (as I do in my applications), they would instantiate a 
format-specific parser.
   
   This approach has the advantage of avoiding Generics, which some developers 
might find challenging or obscure, especially in this particular case. 
   
   Also, the copy constructor that I used in this example wouldn't always be 
necessary.A parser class could also do something like:
   ```
@Override
   public void parse(ExampleParameters parameters) {
if (parameters instanceof AlphaParameters) {
   processAlphaParameters((AlphaParameters) parameters);
   } else {
   processGeneralParameters(parameters);
   }
   ```
   
   Whether we use a copy constructor or a branch as shown above, my overall 
approach does h

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-20 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 20/Jul/21 13:04
Start Date: 20/Jul/21 13:04
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r673102927



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   Maybe forget the whole bit about the copy constructor for 
AlphaParameters.  I think most classes would just do the branching approach and 
only the guys who needed to do something special would use the copy-constructor 
approach.
   
   ```
@Override
   public void parse(ExampleParameters parameters) {
if (parameters instanceof AlphaParameters) {
   processAlphaParameters((AlphaParameters) parameters);
   } else {
   processGeneralParameters(parameters);
   }
   ```




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 625582)
Time Spent: 7h 10m  (was: 7h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 7h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-20 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 20/Jul/21 13:01
Start Date: 20/Jul/21 13:01
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r673100545



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   Here's an idea for a plan (or at least 12 percent of an plan):
   
   In the package example.common, we have the class ExampleParameters and the 
interface ExampleParser
   
   ```
   public class ExampleParameters {
   public int test;
   }
   public interface ExampleParser {
   public void parse(ExampleParameters paramaters);
   }
   ```
   
   There are multiple implementing format packages.  In package 
example.format.alpha, we have
   
   ```
   public class AlphaParameters extends ExampleParameters {
   int mess;
   /**
* A copy constructor
* @param source 
*/
   AlphaParameters(ExampleParameters source){
   this.mess =source.test;
   }
   }
   
   public class AlphaParser implements ExampleParser {
   @Override
   public void parse(ExampleParameters parameters) {
 AlphaParameters alphaParameters;
 if(parameters instanceof AlphaParameters){
  alphaParameters = (AlphaParameters)parameters;
 }else{
  alphaParameters = new AlphaParameters(parameters);
}
 parse(alphaParameters);
   }
   
   public void parse(AlphaParameters parameters){
   // do the work
   }
   }
   
   ```
   
   My thinking is that most applications that have format-specific parameters, 
will call their parser class directly and pass in the specific class that goes 
with it (in this example, AlphaParameter... in real life TiffImagingParameters, 
etc.).   Even those that passed in a generic would experience a small overhead 
for the downcast or the copy constructor...  Those application that are use the 
high-level ImageParser class (which determines format and branches based on 
format type) would pass in an instance of the base class ExampleParameters.  
After all, it's only a small performance hit and if they really have 
format-specific needs (as I do in my applications), they would instantiate a 
format-specific parser.
   
   This approach has the advantage of avoiding Generics, which some developers 
might find challenging or obscure, especially in this particular case. 
   
   Also, the copy constructor that I used in this example wouldn't always be 
necessary.A parser class could also do something like:
   ```
@Override
   public void parse(ExampleParameters parameters) {
if (parameters instanceof AlphaParameters) {
   processAlphaParameters((AlphaParameters) parameters);
   } else {
   processGeneralParameters(parameters);
   }
   ```
   
   This approach has one disadvantage in that we couldn't test for all 
contingencies at com

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-20 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 20/Jul/21 11:49
Start Date: 20/Jul/21 11:49
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r673020403



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   I remember trying that.. now I'm in the process of trying that again, 
and I think I've hit the same wall as in the last time.
   
   The `ImageParser` has some methods like
   
   ```java
   public abstract BufferedImage getBufferedImage(ByteSource byteSource, 
ImagingParameters params)
   throws ImageReadException, IOException;
   ```
   
   Then in `BmpImageParser`, for example, when I try
   
   ```java
   @Override
   public BufferedImage getBufferedImage(final ByteSource byteSource, final 
BmpImagingParameters params)
   throws ImageReadException, IOException {
   ```
   
   It fails due to the `Override` annotation, with `Method does not override 
method from its superclass`. If I rename the parameter to `ImagingParameter`, 
that compiles. But then we could have users sending a `JpegImagingParameters` 
instead, and it would fail in runtime.
   
   I think this is where I stopped last time, and thought I would have to 
either accept `ImagingParameters` everywhere, or use generics... any advice 
@darkma773r ?
   
   Last item pending in this review :tada: 
   
   Thanks!!!
   Bruno




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 625290)
Time Spent: 6h 50m  (was: 6h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 6h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{publ

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-20 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 20/Jul/21 10:59
Start Date: 20/Jul/21 10:59
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r673020403



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   I remember trying that.. now I'm in the process of trying that again, 
and I think I've hit the same wall as in the last time.
   
   The `ImageParser` has some methods like
   
   ```java
   public abstract BufferedImage getBufferedImage(ByteSource byteSource, 
ImagingParameters params)
   throws ImageReadException, IOException;
   ```
   
   Then in `BmpImageParser`, for example, when I try
   
   ```java
   @Override
   public BufferedImage getBufferedImage(final ByteSource byteSource, final 
BmpImagingParameters params)
   throws ImageReadException, IOException {
   ```
   
   It fails due to the `Override` annotation, with `Method does not override 
method from its superclass`. If I rename the parameter to `ImagingParameter`, 
that compiles. But then we could have users sending a `JpegImagingParameters` 
instead, and it would fail in runtime.
   
   I think this is where I stopped last time, and thought I would have to 
either accept `ImagingParameters` everywhere, or use generics... any advice 
@darkma773r ?
   
   Last item pending in this review :tada: 
   
   Thanks!!!
   Bruno




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 625197)
Time Spent: 6h 40m  (was: 6.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 6h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-18 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 18/Jul/21 15:52
Start Date: 18/Jul/21 15:52
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r671862277



##
File path: src/main/java/org/apache/commons/imaging/ImageFormats.java
##
@@ -16,40 +16,92 @@
  */
 package org.apache.commons.imaging;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.imaging.formats.bmp.BmpImagingParameters;
+import org.apache.commons.imaging.formats.gif.GifImagingParameters;
+import org.apache.commons.imaging.formats.icns.IcnsImagingParameters;
+import org.apache.commons.imaging.formats.ico.IcoImagingParameters;
+import org.apache.commons.imaging.formats.jpeg.JpegImagingParameters;
+import org.apache.commons.imaging.formats.pcx.PcxImagingParameters;
+import org.apache.commons.imaging.formats.png.PngImagingParameters;
+import org.apache.commons.imaging.formats.pnm.PnmImagingParameters;
+import org.apache.commons.imaging.formats.psd.PsdImagingParameters;
+import org.apache.commons.imaging.formats.rgbe.RgbeImagingParameters;
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+import org.apache.commons.imaging.formats.wbmp.WbmpImagingParameters;
+import org.apache.commons.imaging.formats.xbm.XbmImagingParameters;
+import org.apache.commons.imaging.formats.xpm.XpmImagingParameters;
+
 /**
  * Enum of known image formats.
  */
 public enum ImageFormats implements ImageFormat {
-UNKNOWN,
-BMP,
-DCX,
-GIF,
-ICNS,
-ICO,
-JBIG2,
-JPEG,
-PAM,
-PSD,
-PBM,
-PGM,
-PNM,
-PPM,
-PCX,
-PNG,
-RGBE,
-TGA,
-TIFF,
-WBMP,
-XBM,
-XPM;
+UNKNOWN(ImagingParameters.class),
+BMP(BmpImagingParameters.class, "bmp", "dib"),
+DCX(PcxImagingParameters.class, "dcx"),
+GIF(GifImagingParameters.class, "gif"),
+ICNS(IcnsImagingParameters.class, "icns"),
+ICO(IcoImagingParameters.class, "ico"),
+JBIG2(ImagingParameters.class),
+JPEG(JpegImagingParameters.class, "jpg", "jpeg"),
+PAM(PnmImagingParameters.class, "pam"),
+PSD(PsdImagingParameters.class, "psd"),
+PBM(PnmImagingParameters.class, "pbm"),
+PGM(PnmImagingParameters.class, "pgm"),
+PNM(PnmImagingParameters.class, "pnm"),
+PPM(PnmImagingParameters.class, "ppm"),
+PCX(PcxImagingParameters.class, "pcx", "pcc"),
+PNG(PngImagingParameters.class, "png"),
+RGBE(RgbeImagingParameters.class, "rgbe"),
+TGA(ImagingParameters.class),
+TIFF(TiffImagingParameters.class, "tif", "tiff"),
+WBMP(WbmpImagingParameters.class, "wbmp"),
+XBM(XbmImagingParameters.class, "xbm"),
+XPM(XpmImagingParameters.class, "xpm");
+
+private static final Logger LOGGER = 
Logger.getLogger(ImageFormats.class.getName());
+
+private String[] extensions;
+private Class parametersClass;
+
+ImageFormats(Class parametersClass, String 
...extensions) {
+this.extensions = extensions;
+this.parametersClass = parametersClass;
+}
 
 @Override
 public String getName() {
 return name();
 }
 
 @Override
-public String getExtension() {
-return name();
+public String[] getExtensions() {
+return this.extensions.clone();
+}
+
+@Override
+public String getDefaultExtension() {
+return this.extensions[0];
+}
+
+@Override
+public ImagingParameters createImagingParameters() {
+ImagingParameters parameters = null;
+if (this.parametersClass != null) {
+Constructor ctor;
+try {
+ctor = this.parametersClass.getConstructor();
+parameters = (ImagingParameters) ctor.newInstance();
+} catch (NoSuchMethodException | SecurityException | 
InstantiationException | IllegalAccessException | IllegalArgumentException | 
InvocationTargetException e) {
+LOGGER.log(Level.WARNING, "Failed to create imaging 
parameters: " + e.getMessage(), e);
+parameters = new ImagingParameters();
+}
+parameters.setImageFormat(this);
+}
+return parameters;

Review comment:
   Woohoo! I learned this trick from Gilles and I pretty much use it all 
the time now :-)




-- 
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-unsubscr...@commons.apache.o

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-18 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 18/Jul/21 10:35
Start Date: 18/Jul/21 10:35
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41452544/badge)](https://coveralls.io/builds/41452544)
   
   Coverage decreased (-0.2%) to 76.565% when pulling 
**4b7f97519ea2712d89100ad0e28138f1a1e94acc on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 624097)
Time Spent: 6h 20m  (was: 6h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 6h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-18 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 18/Jul/21 10:26
Start Date: 18/Jul/21 10:26
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r671819743



##
File path: src/main/java/org/apache/commons/imaging/ImageFormats.java
##
@@ -16,40 +16,92 @@
  */
 package org.apache.commons.imaging;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.imaging.formats.bmp.BmpImagingParameters;
+import org.apache.commons.imaging.formats.gif.GifImagingParameters;
+import org.apache.commons.imaging.formats.icns.IcnsImagingParameters;
+import org.apache.commons.imaging.formats.ico.IcoImagingParameters;
+import org.apache.commons.imaging.formats.jpeg.JpegImagingParameters;
+import org.apache.commons.imaging.formats.pcx.PcxImagingParameters;
+import org.apache.commons.imaging.formats.png.PngImagingParameters;
+import org.apache.commons.imaging.formats.pnm.PnmImagingParameters;
+import org.apache.commons.imaging.formats.psd.PsdImagingParameters;
+import org.apache.commons.imaging.formats.rgbe.RgbeImagingParameters;
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+import org.apache.commons.imaging.formats.wbmp.WbmpImagingParameters;
+import org.apache.commons.imaging.formats.xbm.XbmImagingParameters;
+import org.apache.commons.imaging.formats.xpm.XpmImagingParameters;
+
 /**
  * Enum of known image formats.
  */
 public enum ImageFormats implements ImageFormat {
-UNKNOWN,
-BMP,
-DCX,
-GIF,
-ICNS,
-ICO,
-JBIG2,
-JPEG,
-PAM,
-PSD,
-PBM,
-PGM,
-PNM,
-PPM,
-PCX,
-PNG,
-RGBE,
-TGA,
-TIFF,
-WBMP,
-XBM,
-XPM;
+UNKNOWN(ImagingParameters.class),
+BMP(BmpImagingParameters.class, "bmp", "dib"),
+DCX(PcxImagingParameters.class, "dcx"),
+GIF(GifImagingParameters.class, "gif"),
+ICNS(IcnsImagingParameters.class, "icns"),
+ICO(IcoImagingParameters.class, "ico"),
+JBIG2(ImagingParameters.class),
+JPEG(JpegImagingParameters.class, "jpg", "jpeg"),
+PAM(PnmImagingParameters.class, "pam"),
+PSD(PsdImagingParameters.class, "psd"),
+PBM(PnmImagingParameters.class, "pbm"),
+PGM(PnmImagingParameters.class, "pgm"),
+PNM(PnmImagingParameters.class, "pnm"),
+PPM(PnmImagingParameters.class, "ppm"),
+PCX(PcxImagingParameters.class, "pcx", "pcc"),
+PNG(PngImagingParameters.class, "png"),
+RGBE(RgbeImagingParameters.class, "rgbe"),
+TGA(ImagingParameters.class),
+TIFF(TiffImagingParameters.class, "tif", "tiff"),
+WBMP(WbmpImagingParameters.class, "wbmp"),
+XBM(XbmImagingParameters.class, "xbm"),
+XPM(XpmImagingParameters.class, "xpm");
+
+private static final Logger LOGGER = 
Logger.getLogger(ImageFormats.class.getName());
+
+private String[] extensions;
+private Class parametersClass;
+
+ImageFormats(Class parametersClass, String 
...extensions) {
+this.extensions = extensions;
+this.parametersClass = parametersClass;
+}
 
 @Override
 public String getName() {
 return name();
 }
 
 @Override
-public String getExtension() {
-return name();
+public String[] getExtensions() {
+return this.extensions.clone();
+}
+
+@Override
+public String getDefaultExtension() {
+return this.extensions[0];
+}
+
+@Override
+public ImagingParameters createImagingParameters() {
+ImagingParameters parameters = null;
+if (this.parametersClass != null) {
+Constructor ctor;
+try {
+ctor = this.parametersClass.getConstructor();
+parameters = (ImagingParameters) ctor.newInstance();
+} catch (NoSuchMethodException | SecurityException | 
InstantiationException | IllegalAccessException | IllegalArgumentException | 
InvocationTargetException e) {
+LOGGER.log(Level.WARNING, "Failed to create imaging 
parameters: " + e.getMessage(), e);
+parameters = new ImagingParameters();
+}
+parameters.setImageFormat(this);
+}
+return parameters;

Review comment:
   This was a great advice, and I'm super happy for having asked for 
feedback in the mailing list @darkma773r. It simplified a lot the code. Got to 
remember this trick next time I have a similar situation, I feel like my brain 
is still tuned to use reflections in cases like this...
   
   Thanks!!!




-- 
This is an auto

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/Jul/21 06:22
Start Date: 17/Jul/21 06:22
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41446433/badge)](https://coveralls.io/builds/41446433)
   
   Coverage decreased (-0.2%) to 76.56% when pulling 
**75831b95c9a25ff0d7b09a412bb323ca6a11c20e on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 624006)
Time Spent: 6h  (was: 5h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 6h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/Jul/21 06:17
Start Date: 17/Jul/21 06:17
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r671623444



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -106,7 +98,7 @@
  *
  * @return A valid array of image parsers
  */
-public static ImageParser[] getAllImageParsers() {
+public static ImageParser[] getAllImageParsers() {

Review comment:
   Good idea, 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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 624005)
Time Spent: 5h 50m  (was: 5h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 5h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/Jul/21 05:40
Start Date: 17/Jul/21 05:40
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41446323/badge)](https://coveralls.io/builds/41446323)
   
   Coverage decreased (-0.2%) to 76.563% when pulling 
**622e0b80936e5fa4ae56d426771c30404f578cce on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 624000)
Time Spent: 5h 40m  (was: 5.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 5h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/Jul/21 05:36
Start Date: 17/Jul/21 05:36
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41446310/badge)](https://coveralls.io/builds/41446310)
   
   Coverage decreased (-0.2%) to 76.563% when pulling 
**622e0b80936e5fa4ae56d426771c30404f578cce on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 623999)
Time Spent: 5.5h  (was: 5h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 5.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/Jul/21 05:34
Start Date: 17/Jul/21 05:34
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-881833791


   Excellent review @darkma773r! I've incorporated one of your suggestions 
already, but will need a little more time to go over the other items. However, 
having read your suggestions, I think they will fix other issues I had with the 
current implementation.
   
   Thanks heaps! :champagne: :1st_place_medal: 


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 623998)
Time Spent: 5h 20m  (was: 5h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 5h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/Jul/21 05:32
Start Date: 17/Jul/21 05:32
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r671615265



##
File path: src/main/java/org/apache/commons/imaging/ImagingParameters.java
##
@@ -0,0 +1,108 @@
+/*
+ * 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;
+
+import org.apache.commons.imaging.common.BufferedImageFactory;
+
+/**
+ * Imaging parameters.
+ *
+ * Contains parameters that are common to all formats. Implementations must 
include
+ * the specific parameters for each image format.
+ *
+ * @since 1.0-alpha3
+ */
+public class ImagingParameters {
+
+/**
+ * Whether to throw an exception when any issue occurs during reading
+ * or writing a file format. Default is {@code false}.
+ */
+private boolean strict = false;
+
+/**
+ * An optional file name, used for the description of input streams
+ * where a file name would be hard (or not possible) to be identified.
+ * Default is {@code null}.
+ */
+private String fileName = null;
+
+/**
+ * Factory to create {@code BufferedImage}s. Default is {@code null}.
+ */
+private BufferedImageFactory bufferedImageFactory = null;
+
+/**
+ * Image format used in write operations to indicate desired image format.
+ * Default is {@code null}.
+ *
+ * Valid values: Any format defined in ImageFormat, such as
+ * ImageFormat.IMAGE_FORMAT_PNG.
+ *
+ * @see org.apache.commons.imaging.ImageFormats
+ */
+private ImageFormat imageFormat;

Review comment:
   Excellent idea! That reduced the code smell, where I had a 
`setImageFormat` in the constructor of each parameter class and, as you 
pointed, users could create objects with invalid states. Thanks @darkma773r!




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 623997)
Time Spent: 5h 10m  (was: 5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 5h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 16/Jul/21 19:30
Start Date: 16/Jul/21 19:30
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r671481293



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * The "Map params" argument
+ * The "params" argument
  *
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.
  *
- * Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param  type of parameters used by this image parser
  */
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser extends 
BinaryFileParser {

Review comment:
   Would it make sense to remove this generic parameter and only accept 
`ImagingParameters` in methods? Implementations could downcast as needed to 
access type-specific parameters and this would simplify usage where the image 
format is not known (as in `Imaging`).




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 623827)
Time Spent: 5h  (was: 4h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 16/Jul/21 19:20
Start Date: 16/Jul/21 19:20
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r671476705



##
File path: src/main/java/org/apache/commons/imaging/ImageParser.java
##
@@ -106,7 +98,7 @@
  *
  * @return A valid array of image parsers
  */
-public static ImageParser[] getAllImageParsers() {
+public static ImageParser[] getAllImageParsers() {

Review comment:
   Should this return a list for better compatibility with generics?




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 623818)
Time Spent: 4h 50m  (was: 4h 40m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 4h 50m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 16/Jul/21 19:11
Start Date: 16/Jul/21 19:11
Worklog Time Spent: 10m 
  Work Description: darkma773r commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r671470893



##
File path: src/main/java/org/apache/commons/imaging/ImageFormats.java
##
@@ -16,40 +16,92 @@
  */
 package org.apache.commons.imaging;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.imaging.formats.bmp.BmpImagingParameters;
+import org.apache.commons.imaging.formats.gif.GifImagingParameters;
+import org.apache.commons.imaging.formats.icns.IcnsImagingParameters;
+import org.apache.commons.imaging.formats.ico.IcoImagingParameters;
+import org.apache.commons.imaging.formats.jpeg.JpegImagingParameters;
+import org.apache.commons.imaging.formats.pcx.PcxImagingParameters;
+import org.apache.commons.imaging.formats.png.PngImagingParameters;
+import org.apache.commons.imaging.formats.pnm.PnmImagingParameters;
+import org.apache.commons.imaging.formats.psd.PsdImagingParameters;
+import org.apache.commons.imaging.formats.rgbe.RgbeImagingParameters;
+import org.apache.commons.imaging.formats.tiff.TiffImagingParameters;
+import org.apache.commons.imaging.formats.wbmp.WbmpImagingParameters;
+import org.apache.commons.imaging.formats.xbm.XbmImagingParameters;
+import org.apache.commons.imaging.formats.xpm.XpmImagingParameters;
+
 /**
  * Enum of known image formats.
  */
 public enum ImageFormats implements ImageFormat {
-UNKNOWN,
-BMP,
-DCX,
-GIF,
-ICNS,
-ICO,
-JBIG2,
-JPEG,
-PAM,
-PSD,
-PBM,
-PGM,
-PNM,
-PPM,
-PCX,
-PNG,
-RGBE,
-TGA,
-TIFF,
-WBMP,
-XBM,
-XPM;
+UNKNOWN(ImagingParameters.class),
+BMP(BmpImagingParameters.class, "bmp", "dib"),
+DCX(PcxImagingParameters.class, "dcx"),
+GIF(GifImagingParameters.class, "gif"),
+ICNS(IcnsImagingParameters.class, "icns"),
+ICO(IcoImagingParameters.class, "ico"),
+JBIG2(ImagingParameters.class),
+JPEG(JpegImagingParameters.class, "jpg", "jpeg"),
+PAM(PnmImagingParameters.class, "pam"),
+PSD(PsdImagingParameters.class, "psd"),
+PBM(PnmImagingParameters.class, "pbm"),
+PGM(PnmImagingParameters.class, "pgm"),
+PNM(PnmImagingParameters.class, "pnm"),
+PPM(PnmImagingParameters.class, "ppm"),
+PCX(PcxImagingParameters.class, "pcx", "pcc"),
+PNG(PngImagingParameters.class, "png"),
+RGBE(RgbeImagingParameters.class, "rgbe"),
+TGA(ImagingParameters.class),
+TIFF(TiffImagingParameters.class, "tif", "tiff"),
+WBMP(WbmpImagingParameters.class, "wbmp"),
+XBM(XbmImagingParameters.class, "xbm"),
+XPM(XpmImagingParameters.class, "xpm");
+
+private static final Logger LOGGER = 
Logger.getLogger(ImageFormats.class.getName());
+
+private String[] extensions;
+private Class parametersClass;
+
+ImageFormats(Class parametersClass, String 
...extensions) {
+this.extensions = extensions;
+this.parametersClass = parametersClass;
+}
 
 @Override
 public String getName() {
 return name();
 }
 
 @Override
-public String getExtension() {
-return name();
+public String[] getExtensions() {
+return this.extensions.clone();
+}
+
+@Override
+public String getDefaultExtension() {
+return this.extensions[0];
+}
+
+@Override
+public ImagingParameters createImagingParameters() {
+ImagingParameters parameters = null;
+if (this.parametersClass != null) {
+Constructor ctor;
+try {
+ctor = this.parametersClass.getConstructor();
+parameters = (ImagingParameters) ctor.newInstance();
+} catch (NoSuchMethodException | SecurityException | 
InstantiationException | IllegalAccessException | IllegalArgumentException | 
InvocationTargetException e) {
+LOGGER.log(Level.WARNING, "Failed to create imaging 
parameters: " + e.getMessage(), e);
+parameters = new ImagingParameters();
+}
+parameters.setImageFormat(this);
+}
+return parameters;

Review comment:
   Maybe use factory functions instead of reflection here. Ex:
   ```java
   enum ImageFormat {
   
   PNG(PngImagingParameter::new);
   
   private final Supplier factory;
   
   // 
   public ImagingParameters createImagingParameters() {
   return factory.get();
   }
  
   }
   ```

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-14 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 15/Jul/21 06:07
Start Date: 15/Jul/21 06:07
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41387908/badge)](https://coveralls.io/builds/41387908)
   
   Coverage decreased (-0.1%) to 76.579% when pulling 
**aabd298d703efb5b917506d1f6bc6eddfece3c87 on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 622862)
Time Spent: 4.5h  (was: 4h 20m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 4.5h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-14 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 15/Jul/21 05:27
Start Date: 15/Jul/21 05:27
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841637226


   
   [![Coverage 
Status](https://coveralls.io/builds/41387442/badge)](https://coveralls.io/builds/41387442)
   
   Coverage decreased (-0.2%) to 76.575% when pulling 
**d3ffa1e93188948d4b9f721318a382a7819475cf on kinow:IMAGING-159-1** into 
**a87b545e1019b43bfbe31fa5df3a4f3095a8b438 on apache:master**.
   


-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 622857)
Time Spent: 4h 20m  (was: 4h 10m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 4h 20m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-07-14 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 15/Jul/21 05:24
Start Date: 15/Jul/21 05:24
Worklog Time Spent: 10m 
  Work Description: kinow commented on a change in pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#discussion_r670141981



##
File path: src/main/java/org/apache/commons/imaging/Imaging.java
##
@@ -735,32 +737,35 @@ public static ImageInfo getImageInfo(final File file) 
throws ImageReadException,
 return getImageInfo(file, null);
 }
 
-private static ImageInfo getImageInfo(final ByteSource byteSource, final 
Map params)
-throws ImageReadException, IOException {
-return getImageParser(byteSource).getImageInfo(byteSource, params);
+// See getImageParser
+@SuppressWarnings("unchecked")
+private static ImageInfo getImageInfo(final ByteSource byteSource, final 
ImagingParameters params) throws ImageReadException, IOException {
+return Imaging.getImageParser(byteSource).getImageInfo(byteSource, 
params);
 }
 
-private static ImageParser getImageParser(final ByteSource byteSource)
-throws ImageReadException, IOException {
+// TODO: We have no way of knowing whether the returned ImageParser will 
accept the ImagingParameters,
+// even if we specified generic types for the static methods.

Review comment:
   Not sure if there's a better way of changing this method...




-- 
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-unsubscr...@commons.apache.org

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


Issue Time Tracking
---

Worklog Id: (was: 622856)
Time Spent: 4h 10m  (was: 4h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 4h 10m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-05-17 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/May/21 18:07
Start Date: 17/May/21 18:07
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841797895


   Whew, I knew we relied on awt, but looks like we are using it in a lot more 
places than I imagined. Let me update the PR to use a rectangle as ou suggested 
@gwlucastrig . Thanks!


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

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


Issue Time Tracking
---

Worklog Id: (was: 597883)
Time Spent: 4h  (was: 3h 50m)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 4h
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-05-17 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 17/May/21 18:06
Start Date: 17/May/21 18:06
Worklog Time Spent: 10m 
  Work Description: gwlucastrig commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841791184


   It looks like providing compatibility with Android OS may not be practical.
   Android has its own graphics and media classes.  So anything with java.awt
   in it will not port. Common Imaging using BufferedImage extensively.   Most
   other AWT elements are used only a little.  Color shows up the most.  The
   ICC_ColorSpace also shows up. A couple of the test applications use
   Graphics to draw some test images as input.
   
   I think I might post a question on Java Coderanch or Stackoverflow to ask
   about compatible solutions.
   
   
   On Sat, May 15, 2021 at 8:18 AM Bruno P. Kinoshita ***@***.***>
   wrote:
   
   > If those classes are from awt, the issue is that we have a dependency to
   > java.desktop (I think that's the java module name) and also cause an issue
   > to users of the API that are using Android (as IIUC, there's no awt in
   > Android's Java SDK?).
   >
   > —
   > You are receiving this because you were mentioned.
   > Reply to this email directly, view it on GitHub
   > 
,
   > or unsubscribe
   > 

   > .
   >
   
   Search "java.awt" (229 hits in 121 files of 557 searched)
   commons-imaging\src\main\java\org\apache\commons\imaging\ColorTools.java (11 
hits)
Line 20: import java.awt.RenderingHints;
Line 21: import java.awt.Transparency;
Line 22: import java.awt.color.ColorSpace;
Line 23: import java.awt.color.ICC_ColorSpace;
Line 24: import java.awt.color.ICC_Profile;
Line 25: import java.awt.image.BufferedImage;
Line 26: import java.awt.image.ColorConvertOp;
Line 27: import java.awt.image.ColorModel;
Line 28: import java.awt.image.ComponentColorModel;
Line 29: import java.awt.image.DirectColorModel;
Line 30: import java.awt.image.ImagingOpException;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\BufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\ImageBuilder.java
 (9 hits)
Line 43: import java.awt.color.ColorSpace;
Line 44: import java.awt.image.BufferedImage;
Line 45: import java.awt.image.ColorModel;
Line 46: import java.awt.image.DataBuffer;
Line 47: import java.awt.image.DataBufferInt;
Line 48: import java.awt.image.DirectColorModel;
Line 49: import java.awt.image.Raster;
Line 50: import java.awt.image.RasterFormatException;
Line 51: import java.awt.image.WritableRaster;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\RgbBufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\common\SimpleBufferedImageFactory.java
 (1 hit)
Line 20: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpImageParser.java
 (2 hits)
Line 27: import java.awt.Dimension;
Line 28: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriter.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriterPalette.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\bmp\BmpWriterRgb.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\dcx\DcxImageParser.java
 (2 hits)
Line 23: import java.awt.Dimension;
Line 24: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\gif\GifImageParser.java
 (2 hits)
Line 28: import java.awt.Dimension;
Line 29: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\icns\IcnsDecoder.java
 (1 hit)
Line 19: import java.awt.image.BufferedImage;
   
commons-imaging\src\main\java\org\apache\commons\imaging\formats\icns\IcnsImageParser.java
 (2 hits)
Line 23: import java.awt.Dimension;
Line 24: import java.awt.image.Bu

[jira] [Work logged] (IMAGING-159) There should be a Parameters class

2021-05-16 Thread ASF GitHub Bot (Jira)


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

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

Author: ASF GitHub Bot
Created on: 16/May/21 10:29
Start Date: 16/May/21 10:29
Worklog Time Spent: 10m 
  Work Description: kinow commented on pull request #116:
URL: https://github.com/apache/commons-imaging/pull/116#issuecomment-841797895


   Whew, I knew we relied on awt, but looks like we are using it in a lot more 
places than I imagined. Let me update the PR to use a rectangle as ou suggested 
@gwlucastrig . Thanks!


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

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


Issue Time Tracking
---

Worklog Id: (was: 597367)
Time Spent: 3h 40m  (was: 3.5h)

> There should be a Parameters class
> --
>
> Key: IMAGING-159
> URL: https://issues.apache.org/jira/browse/IMAGING-159
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: imaging.*
>Affects Versions: 1.0-alpha2
>Reporter: Benedikt Ritter
>Assignee: Bruno P. Kinoshita
>Priority: Major
>  Labels: github
> Fix For: 1.0-alpha3
>
>  Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> Currently options for image I/O are defined as Maps. The leads to the problem 
> that our code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
> throw new ImageWriteException(
>   "Invalid compression parameter, must be numeric: "
>  + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides 
> additional methods like {{public int getInt(String key)}}. The implementation 
> could then look up the value from the map through an exception if it is null 
> or not a number.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


  1   2   >