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

  1. Use one of the supported values: png or jpeg (not 'jpg').
  2. Trim and lowercase externally sourced values.
  3. 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

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


AI-assisted analysis of opendataloader-project/opendataloader-pdf@a7789b8e77 (2026-08-14). Data as JSON: /api/errors/7624728c17377db2. Report an issue: GitHub.