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

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

commit 7f1c53eb0ab406e5d2c66a075c4412bf4fdbeea1
Author: Bruno P. Kinoshita <ki...@apache.org>
AuthorDate: Sun Jan 24 00:57:45 2021 +1300

    [IMAGING-159] Add ImagingParameters interface and BaseParameters (POJO)
---
 .../org/apache/commons/imaging/ImageParser.java    |  77 +++-----
 .../java/org/apache/commons/imaging/Imaging.java   | 205 ++++++++-------------
 .../apache/commons/imaging/ImagingConstants.java   |  25 ---
 .../apache/commons/imaging/ImagingParameters.java  |  24 +++
 .../commons/imaging/common/BaseParameters.java     |  92 +++++++++
 .../commons/imaging/common/XmpEmbeddable.java      |   3 +-
 .../imaging/formats/jpeg/iptc/IptcParser.java      |   6 +-
 .../imaging/formats/pcx/PcxImageParser.java        |  14 +-
 .../commons/imaging/formats/pcx/PcxWriter.java     |  12 +-
 .../imaging/formats/xpm/XpmImageParser.java        |  28 +--
 10 files changed, 242 insertions(+), 244 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/ImageParser.java 
b/src/main/java/org/apache/commons/imaging/ImageParser.java
index 812196b..fd653c7 100644
--- a/src/main/java/org/apache/commons/imaging/ImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/ImageParser.java
@@ -26,10 +26,10 @@ import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.commons.imaging.common.BaseParameters;
 import org.apache.commons.imaging.common.BinaryFileParser;
 import org.apache.commons.imaging.common.BufferedImageFactory;
 import org.apache.commons.imaging.common.ImageMetadata;
@@ -79,23 +79,14 @@ import 
org.apache.commons.imaging.formats.xpm.XpmImageParser;
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
  *
- * <h3>The "Map params" argument</h3>
+ * <h3>The "params" argument</h3>
  *
- * 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
+ * <p>Many of the methods specified by this class accept an argument of
+ * type {@code BaseParameters} 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.
- *
- * <p>Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * format compliance.</p>
  */
 public abstract class ImageParser extends BinaryFileParser {
 
@@ -173,7 +164,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            implementation.
      * @throws IOException        In the event of unsuccessful data read 
operation.
      */
-    public abstract ImageMetadata getMetadata(ByteSource byteSource, 
Map<String, Object> params)
+    public abstract ImageMetadata getMetadata(ByteSource byteSource, 
BaseParameters params)
             throws ImageReadException, IOException;
 
     /**
@@ -219,7 +210,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful data read 
operation.
      */
-    public final ImageMetadata getMetadata(final byte[] bytes, final 
Map<String, Object> params)
+    public final ImageMetadata getMetadata(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getMetadata(new ByteSourceArray(bytes), params);
     }
@@ -268,7 +259,7 @@ public abstract class ImageParser extends BinaryFileParser {
      * @throws IOException        In the event of unsuccessful file read or
      *                            access operation.
      */
-    public final ImageMetadata getMetadata(final File file, final Map<String, 
Object> params)
+    public final ImageMetadata getMetadata(final File file, final 
BaseParameters params)
             throws ImageReadException, IOException {
         if (LOGGER.isLoggable(Level.FINEST)) {
             LOGGER.finest(getName() + ".getMetadata" + ": " + file.getName());
@@ -305,7 +296,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful data access 
operation.
      */
-    public abstract ImageInfo getImageInfo(ByteSource byteSource, Map<String, 
Object> params)
+    public abstract ImageInfo getImageInfo(ByteSource byteSource, 
BaseParameters params)
             throws ImageReadException, IOException;
 
     /**
@@ -351,7 +342,7 @@ public abstract class ImageParser extends BinaryFileParser {
      * @throws IOException        In the event of unsuccessful data
      *                            access operation.
      */
-    public final ImageInfo getImageInfo(final byte[] bytes, final Map<String, 
Object> params)
+    public final ImageInfo getImageInfo(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getImageInfo(new ByteSourceArray(bytes), params);
     }
@@ -380,7 +371,7 @@ public abstract class ImageParser extends BinaryFileParser {
      * @throws IOException        In the event of unsuccessful file read or
      *                            access operation.
      */
-    public final ImageInfo getImageInfo(final File file, final Map<String, 
Object> params)
+    public final ImageInfo getImageInfo(final File file, final BaseParameters 
params)
             throws ImageReadException, IOException {
         if (!canAcceptExtension(file)) {
             return null;
@@ -508,7 +499,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public abstract BufferedImage getBufferedImage(ByteSource byteSource, 
Map<String, Object> params)
+    public abstract BufferedImage getBufferedImage(ByteSource byteSource, 
BaseParameters params)
             throws ImageReadException, IOException;
 
     /**
@@ -526,7 +517,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public final BufferedImage getBufferedImage(final byte[] bytes, final 
Map<String, Object> params)
+    public final BufferedImage getBufferedImage(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getBufferedImage(new ByteSourceArray(bytes), params);
     }
@@ -546,7 +537,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public final BufferedImage getBufferedImage(final File file, final 
Map<String, Object> params)
+    public final BufferedImage getBufferedImage(final File file, final 
BaseParameters params)
             throws ImageReadException, IOException {
         if (!canAcceptExtension(file)) {
             return null;
@@ -563,22 +554,18 @@ public abstract class ImageParser extends 
BinaryFileParser {
      * <p>The 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.</p>
      *
      * @param src    An image giving the source content for output
      * @param os     A valid output stream for storing the formatted image
-     * @param params A non-null Map implementation supplying optional,
-     *               format-specific instructions for output
+     * @param params optional parameters, defining format-specific 
instructions for output
      *               (such as selections for data compression, color models, 
etc.)
      * @throws ImageWriteException In the event that the output format
      *                             cannot handle the input image or invalid 
params are specified.
      * @throws IOException         In the event of an write error from
      *                             the output stream.
      */
-    public void writeImage(final BufferedImage src, final OutputStream os, 
final Map<String, Object> params)
+    public void writeImage(final BufferedImage src, final OutputStream os, 
BaseParameters params)
             throws ImageWriteException, IOException {
         os.close(); // we are obligated to close stream.
 
@@ -612,7 +599,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public final Dimension getImageSize(final byte[] bytes, final Map<String, 
Object> params)
+    public final Dimension getImageSize(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getImageSize(new ByteSourceArray(bytes), params);
     }
@@ -643,7 +630,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public final Dimension getImageSize(final File file, final Map<String, 
Object> params)
+    public final Dimension getImageSize(final File file, final BaseParameters 
params)
             throws ImageReadException, IOException {
 
         if (!canAcceptExtension(file)) {
@@ -665,7 +652,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public abstract Dimension getImageSize(ByteSource byteSource, Map<String, 
Object> params)
+    public abstract Dimension getImageSize(ByteSource byteSource, 
BaseParameters params)
             throws ImageReadException, IOException;
 
     /**
@@ -698,7 +685,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public final byte[] getICCProfileBytes(final byte[] bytes, final 
Map<String, Object> params)
+    public final byte[] getICCProfileBytes(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getICCProfileBytes(new ByteSourceArray(bytes), params);
     }
@@ -733,7 +720,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public final byte[] getICCProfileBytes(final File file, final Map<String, 
Object> params)
+    public final byte[] getICCProfileBytes(final File file, final 
BaseParameters params)
             throws ImageReadException, IOException {
         if (!canAcceptExtension(file)) {
             return null;
@@ -760,7 +747,7 @@ public abstract class ImageParser extends BinaryFileParser {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    public abstract byte[] getICCProfileBytes(ByteSource byteSource, 
Map<String, Object> params)
+    public abstract byte[] getICCProfileBytes(ByteSource byteSource, 
BaseParameters params)
             throws ImageReadException, IOException;
 
     /**
@@ -935,16 +922,15 @@ public abstract class ImageParser extends 
BinaryFileParser {
      * of a specification for ImagingConstants.&#46;BUFFERED_IMAGE_FACTORY
      * within the supplied params.
      *
-     * @param params A valid Map object, or a null.
+     * @param params optional parameters.
      * @return A valid instance of an implementation of a 
IBufferedImageFactory.
      */
-    protected BufferedImageFactory getBufferedImageFactory(final Map<String, 
Object> params) {
+    protected BufferedImageFactory getBufferedImageFactory(final 
BaseParameters params) {
         if (params == null) {
             return new SimpleBufferedImageFactory();
         }
 
-        final BufferedImageFactory result = (BufferedImageFactory) params.get(
-                ImagingConstants.BUFFERED_IMAGE_FACTORY);
+        final BufferedImageFactory result = params.getBufferedImageFactory();
 
         if (null != result) {
             return result;
@@ -959,14 +945,11 @@ public abstract class ImageParser extends 
BinaryFileParser {
      * specification. 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.
      */
-    public static boolean isStrict(final Map<String, Object> 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 BaseParameters params) {
+        return params.isStrict();
     }
 }
diff --git a/src/main/java/org/apache/commons/imaging/Imaging.java 
b/src/main/java/org/apache/commons/imaging/Imaging.java
index fd12bce..32a28b0 100644
--- a/src/main/java/org/apache/commons/imaging/Imaging.java
+++ b/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;
-
 import java.awt.Dimension;
 import java.awt.color.ICC_Profile;
 import java.awt.image.BufferedImage;
@@ -29,11 +26,11 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
+import java.util.Objects;
 
+import org.apache.commons.imaging.common.BaseParameters;
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.common.XmpEmbeddable;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
@@ -86,19 +83,13 @@ import org.apache.commons.imaging.icc.IccProfileParser;
  * 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
+ * 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.
  * </p>
  *
- * <p>
- * Optional parameters are specified using a Map object (typically,
- * a Java HashMap) to specify a set of keys and values for input.
- * The specification for support keys is provided by the ImagingConstants
- * interface as well as by format-specific interfaces such as
- * JpegConstants or TiffConstants.
- * </p>
+ * <p>Optional parameters are specified using a {@code BaseParameters} 
object.</p>
  *
  * <h3>Example code</h3>
  *
@@ -365,14 +356,13 @@ public final class Imaging {
      *
      * @param bytes
      *            Byte array containing an image file.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of ICC_Profile or null if the image contains no ICC
      *         profile.
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static ICC_Profile getICCProfile(final byte[] bytes, final 
Map<String, Object> params)
+    public static ICC_Profile getICCProfile(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getICCProfile(new ByteSourceArray(bytes), params);
     }
@@ -403,15 +393,14 @@ public final class Imaging {
      *            InputStream from which to read image data.
      * @param fileName
      *            Filename associated with image data (optional).
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of ICC_Profile or null if the image contains no ICC
      *         profile.
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
     public static ICC_Profile getICCProfile(final InputStream is, final String 
fileName,
-            final Map<String, Object> params) throws ImageReadException, 
IOException {
+            final BaseParameters params) throws ImageReadException, 
IOException {
         return getICCProfile(new ByteSourceInputStream(is, fileName), params);
     }
 
@@ -437,19 +426,18 @@ public final class Imaging {
      *
      * @param file
      *            File containing image data.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of ICC_Profile or null if the image contains no ICC
      *         profile.
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static ICC_Profile getICCProfile(final File file, final Map<String, 
Object> params)
+    public static ICC_Profile getICCProfile(final File file, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getICCProfile(new ByteSourceFile(file), params);
     }
 
-    protected static ICC_Profile getICCProfile(final ByteSource byteSource, 
final Map<String, Object> params)
+    protected static ICC_Profile getICCProfile(final ByteSource byteSource, 
final BaseParameters params)
             throws ImageReadException, IOException {
         final byte[] bytes = getICCProfileBytes(byteSource, params);
         if (bytes == null) {
@@ -497,15 +485,14 @@ public final class Imaging {
      *
      * @param bytes
      *            Byte array containing an image file.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return A byte array.
      * @see IccProfileParser
      * @see ICC_Profile
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static byte[] getICCProfileBytes(final byte[] bytes, final 
Map<String, Object> params)
+    public static byte[] getICCProfileBytes(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getICCProfileBytes(new ByteSourceArray(bytes), params);
     }
@@ -539,20 +526,19 @@ public final class Imaging {
      *
      * @param file
      *            File containing image data.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return A byte array.
      * @see IccProfileParser
      * @see ICC_Profile
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static byte[] getICCProfileBytes(final File file, final Map<String, 
Object> params)
+    public static byte[] getICCProfileBytes(final File file, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getICCProfileBytes(new ByteSourceFile(file), params);
     }
 
-    private static byte[] getICCProfileBytes(final ByteSource byteSource, 
final Map<String, Object> params)
+    private static byte[] getICCProfileBytes(final ByteSource byteSource, 
final BaseParameters params)
             throws ImageReadException, IOException {
         final ImageParser imageParser = getImageParser(byteSource);
 
@@ -571,15 +557,14 @@ public final class Imaging {
      *            String.
      * @param bytes
      *            Byte array containing an image file.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of ImageInfo.
      * @see ImageInfo
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
     public static ImageInfo getImageInfo(final String fileName, final byte[] 
bytes,
-            final Map<String, Object> params) throws ImageReadException, 
IOException {
+            final BaseParameters params) throws ImageReadException, 
IOException {
         return getImageInfo(new ByteSourceArray(fileName, bytes), params);
     }
 
@@ -639,15 +624,14 @@ public final class Imaging {
      *            InputStream from which to read image data.
      * @param fileName
      *            Filename associated with image data (optional).
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of ImageInfo.
      * @see ImageInfo
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
     public static ImageInfo getImageInfo(final InputStream is, final String 
fileName,
-            final Map<String, Object> params) throws ImageReadException, 
IOException {
+            final BaseParameters params) throws ImageReadException, 
IOException {
         return getImageInfo(new ByteSourceInputStream(is, fileName), params);
     }
 
@@ -681,14 +665,13 @@ public final class Imaging {
      *
      * @param bytes
      *            Byte array containing an image file.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of ImageInfo.
      * @see ImageInfo
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static ImageInfo getImageInfo(final byte[] bytes, final Map<String, 
Object> params)
+    public static ImageInfo getImageInfo(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getImageInfo(new ByteSourceArray(bytes), params);
     }
@@ -703,14 +686,13 @@ public final class Imaging {
      *
      * @param file
      *            File containing image data.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of ImageInfo.
      * @see ImageInfo
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static ImageInfo getImageInfo(final File file, final Map<String, 
Object> params)
+    public static ImageInfo getImageInfo(final File file, final BaseParameters 
params)
             throws ImageReadException, IOException {
         return getImageInfo(new ByteSourceFile(file), params);
     }
@@ -735,7 +717,7 @@ public final class Imaging {
         return getImageInfo(file, null);
     }
 
-    private static ImageInfo getImageInfo(final ByteSource byteSource, final 
Map<String, Object> params)
+    private static ImageInfo getImageInfo(final ByteSource byteSource, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getImageParser(byteSource).getImageInfo(byteSource, params);
     }
@@ -793,14 +775,13 @@ public final class Imaging {
      *            InputStream from which to read image data.
      * @param fileName
      *            Filename associated with image data (optional).
-     * @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 InputStream is, final String 
fileName,
-            final Map<String, Object> params) throws ImageReadException, 
IOException {
+            final BaseParameters params) throws ImageReadException, 
IOException {
         return getImageSize(new ByteSourceInputStream(is, fileName), params);
     }
 
@@ -825,13 +806,12 @@ public final class Imaging {
      *
      * @param bytes
      *            Byte array containing an image file.
-     * @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 byte[] bytes, final Map<String, 
Object> params)
+    public static Dimension getImageSize(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getImageSize(new ByteSourceArray(bytes), params);
     }
@@ -857,18 +837,17 @@ public final class Imaging {
      *
      * @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<String, 
Object> params)
+    public static Dimension getImageSize(final File file, final BaseParameters 
params)
             throws ImageReadException, IOException {
         return getImageSize(new ByteSourceFile(file), params);
     }
 
-    public static Dimension getImageSize(final ByteSource byteSource, final 
Map<String, Object> params)
+    public static Dimension getImageSize(final ByteSource byteSource, final 
BaseParameters params)
             throws ImageReadException, IOException {
         final ImageParser imageParser = getImageParser(byteSource);
 
@@ -900,13 +879,12 @@ public final class Imaging {
      *            InputStream from which to read image data.
      * @param fileName
      *            Filename associated with image data (optional).
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return Xmp Xml as String, if present. Otherwise, returns null.
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static String getXmpXml(final InputStream is, final String 
fileName, final Map<String, Object> params)
+    public static String getXmpXml(final InputStream is, final String 
fileName, final BaseParameters params)
             throws ImageReadException, IOException {
         return getXmpXml(new ByteSourceInputStream(is, fileName), params);
     }
@@ -932,13 +910,12 @@ public final class Imaging {
      *
      * @param bytes
      *            Byte array containing an image file.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return Xmp Xml as String, if present. Otherwise, returns null.
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static String getXmpXml(final byte[] bytes, final Map<String, 
Object> params)
+    public static String getXmpXml(final byte[] bytes, final BaseParameters 
params)
             throws ImageReadException, IOException {
         return getXmpXml(new ByteSourceArray(bytes), params);
     }
@@ -964,13 +941,12 @@ public final class Imaging {
      *
      * @param file
      *            File containing image data.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return Xmp Xml as String, if present. Otherwise, returns null.
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static String getXmpXml(final File file, final Map<String, Object> 
params)
+    public static String getXmpXml(final File file, final BaseParameters 
params)
             throws ImageReadException, IOException {
         return getXmpXml(new ByteSourceFile(file), params);
     }
@@ -981,13 +957,12 @@ public final class Imaging {
      *
      * @param byteSource
      *            File containing image data.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return Xmp Xml as String, if present. Otherwise, returns null.
      * @throws ImageReadException if it fails to parse the image
      * @throws IOException if it fails to read the image data
      */
-    public static String getXmpXml(final ByteSource byteSource, final 
Map<String, Object> params)
+    public static String getXmpXml(final ByteSource byteSource, final 
BaseParameters params)
             throws ImageReadException, IOException {
         final ImageParser imageParser = getImageParser(byteSource);
         if (imageParser instanceof XmpEmbeddable) {
@@ -1036,14 +1011,13 @@ public final class Imaging {
      *
      * @param bytes
      *            Byte array containing an image file.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters
      * @return An instance of IImageMetadata.
      * @see org.apache.commons.imaging.common.ImageMetadata
      * @throws ImageReadException if it fails to read the image metadata
      * @throws IOException if it fails to read the image data
      */
-    public static ImageMetadata getMetadata(final byte[] bytes, final 
Map<String, Object> params)
+    public static ImageMetadata getMetadata(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getMetadata(new ByteSourceArray(bytes), params);
     }
@@ -1092,15 +1066,14 @@ public final class Imaging {
      *            InputStream from which to read image data.
      * @param fileName
      *            Filename associated with image data (optional).
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of IImageMetadata.
      * @see org.apache.commons.imaging.common.ImageMetadata
      * @throws ImageReadException if it fails to read the image metadata
      * @throws IOException if it fails to read the image data
      */
     public static ImageMetadata getMetadata(final InputStream is, final String 
fileName,
-            final Map<String, Object> params) throws ImageReadException, 
IOException {
+            final BaseParameters params) throws ImageReadException, 
IOException {
         return getMetadata(new ByteSourceInputStream(is, fileName), params);
     }
 
@@ -1144,19 +1117,18 @@ public final class Imaging {
      *
      * @param file
      *            File containing image data.
-     * @param params
-     *            Map of optional parameters, defined in ImagingConstants.
+     * @param params optional parameters.
      * @return An instance of IImageMetadata.
      * @see org.apache.commons.imaging.common.ImageMetadata
      * @throws ImageReadException if it fails to read the image metadata
      * @throws IOException if it fails to read the image data
      */
-    public static ImageMetadata getMetadata(final File file, final Map<String, 
Object> params)
+    public static ImageMetadata getMetadata(final File file, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getMetadata(new ByteSourceFile(file), params);
     }
 
-    private static ImageMetadata getMetadata(final ByteSource byteSource, 
final Map<String, Object> params)
+    private static ImageMetadata getMetadata(final ByteSource byteSource, 
final BaseParameters params)
             throws ImageReadException, IOException {
         final ImageParser imageParser = getImageParser(byteSource);
 
@@ -1323,7 +1295,7 @@ public final class Imaging {
     /**
      * Reads the first image from an InputStream
      * using data-processing options specified through a parameters
-     * map.  Options may be configured using the ImagingConstants
+     * object.  Options may be configured using the ImagingConstants
      * interface or the various format-specific implementations provided
      * by this package.
      * <p>
@@ -1334,18 +1306,15 @@ public final class Imaging {
      * image info, metadata and ICC profiles from all image formats that
      * provide this data.
      * @param is a valid ImageStream from which to read data.
-     * @param params an optional parameters map specifying options
+     * @param params optional parameters.
      * @return if successful, a valid buffered image
      * @throws ImageReadException in the event of a processing error
      * while reading an image (i.e. a format violation, etc.).
      * @throws IOException  in the event of an unrecoverable I/O exception.
      */
-    public static BufferedImage getBufferedImage(final InputStream is, final 
Map<String, Object> params)
+    public static BufferedImage getBufferedImage(final InputStream is, final 
BaseParameters params)
             throws ImageReadException, IOException {
-        String fileName = null;
-        if (params != null && params.containsKey(PARAM_KEY_FILENAME)) {
-            fileName = (String) params.get(PARAM_KEY_FILENAME);
-        }
+        String fileName = params != null ? "" : null;
         return getBufferedImage(new ByteSourceInputStream(is, fileName), 
params);
     }
 
@@ -1373,31 +1342,29 @@ public final class Imaging {
     /**
      * Reads the first image from a byte array
      * using data-processing options specified through a parameters
-     * map.  Options may be configured using the ImagingConstants
+     * {@code BaseParameters}. Options may be configured using the 
ImagingConstants
      * interface or the various format-specific implementations provided
      * by this package.
-     * <p>
-     * For the most recent information on support for specific formats, refer 
to
+     *
+     * <p>For the most recent information on support for specific formats, 
refer to
      * <a href="https://commons.apache.org/imaging/formatsupport.html";>Format 
Support</a>
      * at the main project development web site.   While the Apache Commons
      * Imaging package does not fully support all formats, it  can read
      * image info, metadata and ICC profiles from all image formats that
-     * provide this data.
+     * provide this data.</p>
+     *
      * @param bytes a valid array of bytes from which to read data.
-     * @param params an optional parameters map specifying options.
+     * @param params an optional parameters object.
      * @return if successful, a valid buffered image
      * @throws ImageReadException in the event of a processing error
      * while reading an image (i.e. a format violation, etc.).
      * @throws IOException  in the event of an unrecoverable I/O exception.
      */
-    public static BufferedImage getBufferedImage(final byte[] bytes, final 
Map<String, Object> params)
+    public static BufferedImage getBufferedImage(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return getBufferedImage(new ByteSourceArray(bytes), params);
     }
 
-
-
-
     /**
      * Reads the first image from a file.
      * <p>
@@ -1422,7 +1389,7 @@ public final class Imaging {
     /**
      * Reads the first image from a file
      * using data-processing options specified through a parameters
-     * map.  Options may be configured using the ImagingConstants
+     * object. Options may be configured using the ImagingConstants
      * interface or the various format-specific implementations provided
      * by this package.
      * <p>
@@ -1433,13 +1400,13 @@ public final class Imaging {
      * image info, metadata and ICC profiles from all image formats that
      * provide this data.
      * @param file a valid reference to a file containing image data.
-     * @param params parameters map.
+     * @param params optional parameters.
      * @return if successful, a valid buffered image
      * @throws ImageReadException in the event of a processing error
      * while reading an image (i.e. a format violation, etc.).
      * @throws IOException  in the event of an unrecoverable I/O exception.
      */
-    public static BufferedImage getBufferedImage(final File file, final 
Map<String, Object> params)
+    public static BufferedImage getBufferedImage(final File file, 
BaseParameters params)
             throws ImageReadException, IOException {
         return getBufferedImage(new ByteSourceFile(file), params);
     }
@@ -1447,20 +1414,16 @@ public final class Imaging {
 
 
     private static BufferedImage getBufferedImage(final ByteSource byteSource,
-            Map<String, Object> params) throws ImageReadException, IOException 
{
+            BaseParameters params) throws ImageReadException, IOException {
         final ImageParser imageParser = getImageParser(byteSource);
-        if (null == params) {
-            params = new HashMap<>();
-        }
-
         return imageParser.getBufferedImage(byteSource, params);
     }
 
      /**
      * Writes the content of a BufferedImage to a file using the specified
      * image format.  Specifications for storing the file (such as data 
compression,
-     * color models, metadata tags, etc.) may be specified using an optional
-     * parameters map. These specifications are defined in the ImagingConstants
+     * color models, metadata tags, etc.) may be specified using optional
+     * parameters. These specifications are defined in the ImagingConstants
      * interface or in various format-specific implementations.
      * <p>
      * Image writing is not supported for all graphics formats.
@@ -1472,19 +1435,18 @@ public final class Imaging {
      * provide this data.
      * @param src a valid BufferedImage object
      * @param file the file to which the output image is to be written
-     * @param format the format in which the output image is to be written
-     * @param params an optional parameters map (nulls permitted)
+     * @param params optional parameters
      * @throws ImageWriteException in the event of a format violation,
      * unsupported image format, etc.
      * @throws IOException in the event of an unrecoverable I/O exception.
      * @see ImagingConstants
      */
     public static void writeImage(final BufferedImage src, final File file,
-            final ImageFormat format, final Map<String, Object> params) throws 
ImageWriteException,
+            final BaseParameters params) throws ImageWriteException,
             IOException {
         try (FileOutputStream fos = new FileOutputStream(file);
                 BufferedOutputStream os = new BufferedOutputStream(fos)) {
-            writeImage(src, os, format, params);
+            writeImage(src, os, params);
         }
     }
 
@@ -1492,8 +1454,8 @@ public final class Imaging {
     /**
      * Writes the content of a BufferedImage to a byte array using the 
specified
      * image format.  Specifications for storing the file (such as data 
compression,
-     * color models, metadata tags, etc.) may be specified using an optional
-     * parameters map. These specifications are defined in the ImagingConstants
+     * color models, metadata tags, etc.) may be specified using optional
+     * parameters. These specifications are defined in the ImagingConstants
      * interface or in various format-specific implementations.
      * <p>
      * Image writing is not supported for all graphics formats.
@@ -1504,8 +1466,7 @@ public final class Imaging {
      * image info, metadata and ICC profiles from all image formats that
      * provide this data.
      * @param src a valid BufferedImage object
-     * @param format the format in which the output image is to be written
-     * @param params an optional parameters map (nulls permitted)
+     * @param params optional parameters
      * @return if successful, a valid array of bytes.
      * @throws ImageWriteException in the event of a format violation,
      * unsupported image format, etc.
@@ -1513,11 +1474,11 @@ public final class Imaging {
      * @see ImagingConstants
      */
     public static byte[] writeImageToBytes(final BufferedImage src,
-            final ImageFormat format, final Map<String, Object> params) throws 
ImageWriteException,
+            final BaseParameters params) throws ImageWriteException,
             IOException {
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
 
-        writeImage(src, os, format, params);
+        writeImage(src, os, params);
 
         return os.toByteArray();
     }
@@ -1526,9 +1487,8 @@ public final class Imaging {
      /**
      * Writes the content of a BufferedImage to an OutputStream using the 
specified
      * image format.  Specifications for storing the file (such as data 
compression,
-     * color models, metadata tags, etc.) may be specified using an optional
-     * parameters map. These specifications are defined in the ImagingConstants
-     * interface or in various format-specific implementations.
+     * color models, metadata tags, etc.) may be specified using optional
+     * parameters.
      * <p>
      * Image writing is not supported for all graphics formats.
      * For the most recent information on support for specific formats, refer 
to
@@ -1539,34 +1499,27 @@ public final class Imaging {
      * provide this data.
      * @param src a valid BufferedImage object
      * @param os the OutputStream to which the output image is to be written
-     * @param format the format in which the output image is to be written
-     * @param params an optional parameters map (nulls permitted)
+     * @param params optional parameters
      * @throws ImageWriteException in the event of a format violation,
      * unsupported image format, etc.
      * @throws IOException in the event of an unrecoverable I/O exception.
      * @see ImagingConstants
      */
     public static void writeImage(final BufferedImage src, final OutputStream 
os,
-            final ImageFormat format, Map<String, Object> params) throws 
ImageWriteException,
+            BaseParameters params) throws ImageWriteException,
             IOException {
+        Objects.requireNonNull(params, "You must provide a valid imaging 
parameters object.");
         final ImageParser[] imageParsers = ImageParser.getAllImageParsers();
 
-        // make sure params are non-null
-        if (params == null) {
-            params = new HashMap<>();
-        }
-
-        params.put(PARAM_KEY_FORMAT, format);
-
         ImageParser imageParser = null;
         for (final ImageParser imageParser2 : imageParsers) {
-            if (imageParser2.canAcceptType(format)) {
+            if (imageParser2.canAcceptType(params.getImageFormat())) {
                 imageParser = imageParser2;
                 break;
             }
         }
         if (imageParser == null) {
-            throw new ImageWriteException("Unknown Format: " + format);
+            throw new ImageWriteException("Unknown Format: " + 
params.getImageFormat());
         }
         imageParser.writeImage(src, os, params);
     }
diff --git a/src/main/java/org/apache/commons/imaging/ImagingConstants.java 
b/src/main/java/org/apache/commons/imaging/ImagingConstants.java
index 47a3413..d25430d 100644
--- a/src/main/java/org/apache/commons/imaging/ImagingConstants.java
+++ b/src/main/java/org/apache/commons/imaging/ImagingConstants.java
@@ -26,29 +26,6 @@ package org.apache.commons.imaging;
 public final class ImagingConstants {
 
     /**
-     * <p>Parameter key. Used to hint the file name when reading from a byte 
array
-     * or InputStream. The file name hint can help disambiguate what file the
-     * image format.</p>
-     *
-     * <p>Applies to read operations.</p>
-     *
-     * <p>Valid values: file name as string</p>
-     *
-     * @see java.io.InputStream
-     */
-    public static final String PARAM_KEY_FILENAME = "FILENAME";
-
-    /**
-     * <p>Parameter key. Used in write operations to indicate desired image 
format.</p>
-     *
-     * <p>Valid values: Any format defined in ImageFormat, such as
-     * ImageFormat.IMAGE_FORMAT_PNG.</p>
-     *
-     * @see org.apache.commons.imaging.ImageFormats
-     */
-    public static final String PARAM_KEY_FORMAT = "FORMAT";
-
-    /**
      * <p>Parameter key. Used in write operations to indicate desired 
compression
      * algorithm.</p>
      *
@@ -63,8 +40,6 @@ public final class ImagingConstants {
      */
     public static final String PARAM_KEY_COMPRESSION = "COMPRESSION";
 
-    public static final String BUFFERED_IMAGE_FACTORY = 
"BUFFERED_IMAGE_FACTORY";
-
     /**
      * <p>Parameter key. Indicates whether to read embedded thumbnails.</p>
      *
diff --git a/src/main/java/org/apache/commons/imaging/ImagingParameters.java 
b/src/main/java/org/apache/commons/imaging/ImagingParameters.java
new file mode 100644
index 0000000..6f39916
--- /dev/null
+++ b/src/main/java/org/apache/commons/imaging/ImagingParameters.java
@@ -0,0 +1,24 @@
+/*
+ * 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;
+
+/**
+ * Imaging parameters.
+ *
+ * @since 1.0-alpha3
+ */
+public interface ImagingParameters {}
diff --git 
a/src/main/java/org/apache/commons/imaging/common/BaseParameters.java 
b/src/main/java/org/apache/commons/imaging/common/BaseParameters.java
new file mode 100644
index 0000000..3e8e4c9
--- /dev/null
+++ b/src/main/java/org/apache/commons/imaging/common/BaseParameters.java
@@ -0,0 +1,92 @@
+/*
+ * 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.common;
+
+import org.apache.commons.imaging.ImageFormat;
+import org.apache.commons.imaging.ImagingParameters;
+
+/**
+ * Set of parameters that are common to all imaging formats.
+ *
+ * @since 1.0-alpha3
+ */
+public class BaseParameters implements 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}.
+     *
+     * <p>Valid values: Any format defined in ImageFormat, such as
+     * ImageFormat.IMAGE_FORMAT_PNG.</p>
+     *
+     * @see org.apache.commons.imaging.ImageFormats
+     */
+    private ImageFormat imageFormat;
+
+    // getters and setters
+
+    public boolean isStrict() {
+        return strict;
+    }
+
+    public void setStrict(boolean strict) {
+        this.strict = strict;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public BufferedImageFactory getBufferedImageFactory() {
+        return bufferedImageFactory;
+    }
+
+    public void setBufferedImageFactory(BufferedImageFactory 
bufferedImageFactory) {
+        this.bufferedImageFactory = bufferedImageFactory;
+    }
+
+    public ImageFormat getImageFormat() {
+        return imageFormat;
+    }
+
+    public void setImageFormat(ImageFormat imageFormat) {
+        this.imageFormat = imageFormat;
+    }
+
+}
diff --git a/src/main/java/org/apache/commons/imaging/common/XmpEmbeddable.java 
b/src/main/java/org/apache/commons/imaging/common/XmpEmbeddable.java
index 66f52cc..4c3f2ce 100644
--- a/src/main/java/org/apache/commons/imaging/common/XmpEmbeddable.java
+++ b/src/main/java/org/apache/commons/imaging/common/XmpEmbeddable.java
@@ -17,7 +17,6 @@
 package org.apache.commons.imaging.common;
 
 import java.io.IOException;
-import java.util.Map;
 
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
@@ -48,7 +47,7 @@ public interface XmpEmbeddable {
      *                            parser implementation.
      * @throws IOException        In the event of unsuccessful read or access 
operation.
      */
-    String getXmpXml(ByteSource byteSource, Map<String, Object> params)
+    String getXmpXml(ByteSource byteSource, BaseParameters params)
             throws ImageReadException, IOException;
 
 }
diff --git 
a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java 
b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
index f5c2adc..1fa5ba1 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java
@@ -36,7 +36,6 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -44,6 +43,7 @@ import java.util.logging.Logger;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.ImagingConstants;
+import org.apache.commons.imaging.common.BaseParameters;
 import org.apache.commons.imaging.common.BinaryFileParser;
 import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.BinaryOutputStream;
@@ -123,9 +123,9 @@ public class IptcParser extends BinaryFileParser {
      * Some IPTC blocks are missing this first "record version" record, so we
      * don't require it.
      */
-    public PhotoshopApp13Data parsePhotoshopSegment(final byte[] bytes, final 
Map<String, Object> params)
+    public PhotoshopApp13Data parsePhotoshopSegment(final byte[] bytes, final 
BaseParameters params)
             throws ImageReadException, IOException {
-        final boolean strict =  params != null && 
Boolean.TRUE.equals(params.get(ImagingConstants.PARAM_KEY_STRICT));
+        final boolean strict =  params != null && params.isStrict();
 
         return parsePhotoshopSegment(bytes, strict);
     }
diff --git 
a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java 
b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
index d370259..c98cdd4 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
@@ -49,6 +49,7 @@ import org.apache.commons.imaging.ImageInfo;
 import org.apache.commons.imaging.ImageParser;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
+import org.apache.commons.imaging.common.BaseParameters;
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 
@@ -474,22 +475,15 @@ public class PcxImageParser extends ImageParser {
 
     @Override
     public final BufferedImage getBufferedImage(final ByteSource byteSource,
-            Map<String, Object> params) throws ImageReadException, IOException 
{
-        params = (params == null) ? new HashMap<>() : new HashMap<>(params);
-        boolean isStrict = false;
-        final Object strictness = params.get(PARAM_KEY_STRICT);
-        if (strictness != null) {
-            isStrict = ((Boolean) strictness).booleanValue();
-        }
-
+            BaseParameters params) throws ImageReadException, IOException {
         try (InputStream is = byteSource.getInputStream()) {
-            final PcxHeader pcxHeader = readPcxHeader(is, isStrict);
+            final PcxHeader pcxHeader = readPcxHeader(is, params.isStrict());
             return readImage(pcxHeader, is, byteSource);
         }
     }
 
     @Override
-    public void writeImage(final BufferedImage src, final OutputStream os, 
final Map<String, Object> params)
+    public void writeImage(final BufferedImage src, final OutputStream os, 
final BaseParameters params)
             throws ImageWriteException, IOException {
         new PcxWriter(params).writeImage(src, os);
     }
diff --git 
a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java 
b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
index a238d3e..c89043a 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
@@ -21,11 +21,11 @@ import java.io.OutputStream;
 import java.nio.ByteOrder;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.ImagingConstants;
 import org.apache.commons.imaging.PixelDensity;
+import org.apache.commons.imaging.common.BaseParameters;
 import org.apache.commons.imaging.common.BinaryOutputStream;
 import org.apache.commons.imaging.palette.PaletteFactory;
 import org.apache.commons.imaging.palette.SimplePalette;
@@ -37,15 +37,7 @@ class PcxWriter {
     private PixelDensity pixelDensity;
     private final RleWriter rleWriter;
 
-    PcxWriter(Map<String, Object> params) throws ImageWriteException {
-        // make copy of params; we'll clear keys as we consume them.
-        params = (params == null) ? new HashMap<>() : new HashMap<>(params);
-
-        // clear format key.
-        if (params.containsKey(ImagingConstants.PARAM_KEY_FORMAT)) {
-            params.remove(ImagingConstants.PARAM_KEY_FORMAT);
-        }
-
+    PcxWriter(BaseParameters params) throws ImageWriteException {
         // uncompressed PCX files are not even documented in ZSoft's spec,
         // let alone supported by most image viewers
         encoding = PcxImageParser.PcxHeader.ENCODING_RLE;
diff --git 
a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java 
b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
index 43006be..a625923 100644
--- a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
@@ -13,8 +13,6 @@
  */
 package org.apache.commons.imaging.formats.xpm;
 
-import static org.apache.commons.imaging.ImagingConstants.PARAM_KEY_FORMAT;
-
 import java.awt.Dimension;
 import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
@@ -47,6 +45,7 @@ import org.apache.commons.imaging.ImageInfo;
 import org.apache.commons.imaging.ImageParser;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.ImageWriteException;
+import org.apache.commons.imaging.common.BaseParameters;
 import org.apache.commons.imaging.common.BasicCParser;
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
@@ -127,13 +126,13 @@ public class XpmImageParser extends ImageParser {
     }
 
     @Override
-    public ImageMetadata getMetadata(final ByteSource byteSource, final 
Map<String, Object> params)
+    public ImageMetadata getMetadata(final ByteSource byteSource, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return null;
     }
 
     @Override
-    public ImageInfo getImageInfo(final ByteSource byteSource, final 
Map<String, Object> params)
+    public ImageInfo getImageInfo(final ByteSource byteSource, final 
BaseParameters params)
             throws ImageReadException, IOException {
         final XpmHeader xpmHeader = readXpmHeader(byteSource);
         boolean transparent = false;
@@ -158,14 +157,14 @@ public class XpmImageParser extends ImageParser {
     }
 
     @Override
-    public Dimension getImageSize(final ByteSource byteSource, final 
Map<String, Object> params)
+    public Dimension getImageSize(final ByteSource byteSource, final 
BaseParameters params)
             throws ImageReadException, IOException {
         final XpmHeader xpmHeader = readXpmHeader(byteSource);
         return new Dimension(xpmHeader.width, xpmHeader.height);
     }
 
     @Override
-    public byte[] getICCProfileBytes(final ByteSource byteSource, final 
Map<String, Object> params)
+    public byte[] getICCProfileBytes(final ByteSource byteSource, final 
BaseParameters params)
             throws ImageReadException, IOException {
         return null;
     }
@@ -598,7 +597,7 @@ public class XpmImageParser extends ImageParser {
 
     @Override
     public final BufferedImage getBufferedImage(final ByteSource byteSource,
-            final Map<String, Object> params) throws ImageReadException, 
IOException {
+            final BaseParameters params) throws ImageReadException, 
IOException {
         final XpmParseResult result = parseXpmHeader(byteSource);
         return readXpmImage(result.xpmHeader, result.cParser);
     }
@@ -644,21 +643,8 @@ public class XpmImageParser extends ImageParser {
     }
 
     @Override
-    public void writeImage(final BufferedImage src, final OutputStream os, 
Map<String, Object> params)
+    public void writeImage(final BufferedImage src, final OutputStream os, 
BaseParameters params)
             throws ImageWriteException, IOException {
-        // make copy of params; we'll clear keys as we consume them.
-        params = (params == null) ? new HashMap<>() : new HashMap<>(params);
-
-        // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT)) {
-            params.remove(PARAM_KEY_FORMAT);
-        }
-
-        if (!params.isEmpty()) {
-            final Object firstKey = params.keySet().iterator().next();
-            throw new ImageWriteException("Unknown parameter: " + firstKey);
-        }
-
         final PaletteFactory paletteFactory = new PaletteFactory();
         final boolean hasTransparency = paletteFactory.hasTransparency(src, 1);
         SimplePalette palette = null;

Reply via email to