lehmi commented on code in PR #210:
URL: https://github.com/apache/pdfbox/pull/210#discussion_r2203243491


##########
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java:
##########
@@ -383,6 +383,69 @@ public static PDImageXObject 
createFromByteArray(PDDocument document, byte[] byt
         throw new IllegalArgumentException("Image type " + fileType + " not 
supported: " + name);
     }
 
+    /**
+     * Create a PDImageXObject from an image byte array. This overloaded 
version allows providing 
+     * a custom factory to handle specific image formats, such as BMP and GIF, 
or to act as a 
+     * fallback strategy when the default converters (e.g., for PNG or TIFF) 
fail.
+     *
+     * @param document the document that shall use this PDImageXObject.
+     * @param byteArray bytes from an image file.
+     * @param name name of image file for exception messages, can be null.
+     * @param defaultFactory optional factory used to handle BMP, GIF, or 
fallback cases 
+     *                       (e.g., for PNG or TIFF). If {@code null}, this 
method delegates to
+     *                       {@link #createFromByteArray(PDDocument, byte[], 
String)}.
+     * @return a PDImageXObject.
+     * @throws IOException if there is an error when reading the file or 
creating the
+     * PDImageXObject.
+     * @throws IllegalArgumentException if the image type is not supported.
+     */
+    public static PDImageXObject createFromByteArray(PDDocument document, 
byte[] byteArray, String name, DefaultFactory defaultFactory) throws IOException

Review Comment:
   I've proposed DefaultFactory and I'm not really happy with that name. Maybe 
alter
   
   Fallback won't be correct as it isn't a fallback in all cases. It is for png 
and tiff which can't be processed but it isn't for bmp and gif.
   
   How about CustomFactory?



-- 
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: dev-unsubscr...@pdfbox.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to