opendataloader-project/opendataloader-pdf · error · IllegalArgumentException
Unsupported image format '%s'. Supported values: %s
Error message
Unsupported image format '%s'. Supported values: %s
What it means
Config.setImageFormat rejects any value not in {png, jpeg}. The check is case-insensitive (lowercased) but does not trim whitespace. null is accepted and defaults to png. IllegalArgumentException is thrown before assignment.
Source
Thrown at java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/Config.java:629
/**
* Gets the image format for extracted images.
*
* @return The image format (png or jpeg).
*/
public String getImageFormat() {
return imageFormat;
}
/**
* Sets the image format for extracted images.
*
* @param imageFormat The image format (png or jpeg).
* @throws IllegalArgumentException if the format is not supported.
*/
public void setImageFormat(String imageFormat) {
if (imageFormat != null && !isValidImageFormat(imageFormat)) {
throw new IllegalArgumentException(
String.format("Unsupported image format '%s'. Supported values: %s",
imageFormat, getImageFormatOptions(", ")));
}
this.imageFormat = imageFormat != null ? imageFormat.toLowerCase(Locale.ROOT) : IMAGE_FORMAT_PNG;
}
/**
* Gets the list of supported image format options.
*
* @param delimiter The delimiter to use between options.
* @return The string with image formats separated by the delimiter.
*/
public static String getImageFormatOptions(CharSequence delimiter) {
return String.join(delimiter, imageFormatOptions);
}
/**
* Checks if the given image format is valid.View on GitHub (pinned to a7789b8e77)
Solutions
- Use one of the supported values: png or jpeg (not 'jpg').
- Trim and lowercase externally sourced values.
- Pre-validate with Config.isValidImageFormat(value).
Example fix
// before: config.setImageFormat("jpg");
// after: config.setImageFormat("jpeg"); Defensive patterns
Strategy: validation
Validate before calling
String fmt = externalValue == null ? null : externalValue.trim().toLowerCase(Locale.ROOT);
if (fmt != null && !Config.isValidImageFormat(fmt)) {
throw new IllegalArgumentException(
"Bad --image-format '" + fmt + "'. Valid: " + Config.getImageFormatOptions(", "));
}
config.setImageFormat(fmt); Type guard
static boolean isSupportedImageFormat(String s) {
return s != null && Config.isValidImageFormat(s.trim());
} Try / catch
try {
config.setImageFormat(raw);
} catch (IllegalArgumentException e) {
config.setImageFormat(null); // default png
} Prevention
- Remember 'jpg' is NOT accepted; only 'jpeg' and 'png'.
- Trim and lowercase external values before validation.
When it happens
Trigger: config.setImageFormat("jpg") or config.setImageFormat("tiff"); CLI --image-format jpg. Note 'jpg' is NOT accepted (only 'jpeg').
Common situations: Using the common 'jpg' alias (unsupported here); typo; value from a different version; untrimmed value.
Related errors
- Unsupported table method '%s'. Supported values: %s
- Unsupported reading order '%s'. Supported values: %s
- Unsupported image output mode '%s'. Supported values: %s
- Invalid page range format: '%s'. Expected format: 1,3,5-7
- Page numbers must be positive: '%s'
AI-assisted analysis of opendataloader-project/opendataloader-pdf@a7789b8e77 (2026-08-14).
Data as JSON: /api/errors/7624728c17377db2.
Report an issue: GitHub.