opendataloader-project/opendataloader-pdf · error · IllegalArgumentException
Option --image-resolution requires valid double value.
Error message
Option --image-resolution requires valid double value.
What it means
Thrown when --image-resolution holds a value that Double.parseDouble cannot interpret as a number (NumberFormatException). This fires only for genuinely unparseable input; a value that parses but is non-positive or non-finite triggers the sibling error 22 instead, because the parse succeeds before the range check runs.
Source
Thrown at java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java:489
if (!Config.isValidImageFormat(format)) {
throw new IllegalArgumentException(
String.format("Unsupported image format '%s'. Supported values: png, jpeg", format));
}
config.setImageFormat(format);
}
if (commandLine.hasOption(IMAGE_DIR_LONG_OPTION)) {
config.setImageDir(commandLine.getOptionValue(IMAGE_DIR_LONG_OPTION));
}
if (commandLine.hasOption(IMAGE_RESOLUTION_LONG_OPTION)) {
try {
double imageResolution = Double.parseDouble(commandLine.getOptionValue(IMAGE_RESOLUTION_LONG_OPTION));
if (!Double.isFinite(imageResolution) || imageResolution <= 0) {
throw new IllegalArgumentException(
"Option --image-resolution requires a finite positive double value.");
}
config.setImageResolution(imageResolution);
} catch (NumberFormatException e) {
throw new IllegalArgumentException(
"Option --image-resolution requires valid double value.", e);
}
}
}
private static void applyPagesOption(Config config, CommandLine commandLine) {
if (commandLine.hasOption(PAGES_LONG_OPTION)) {
config.setPages(commandLine.getOptionValue(PAGES_LONG_OPTION));
}
}
private static void applyTableMethodOption(Config config, CommandLine commandLine) {
if (commandLine.hasOption(TABLE_METHOD_LONG_OPTION)) {
String methodValue = commandLine.getOptionValue(TABLE_METHOD_LONG_OPTION);
if (methodValue == null || methodValue.trim().isEmpty()) {
throw new IllegalArgumentException(
String.format("Option --table-method requires a value. Supported values: %s",
Config.getTableMethodOptions(", ")));View on GitHub (pinned to a7789b8e77)
Solutions
- Use a plain decimal number with a point separator: `--image-resolution 150.0`.
- Strip any units/suffixes and commas before passing.
- Verify the shell variable expands to a number, not empty or text.
Example fix
// before opendataloader-pdf doc.pdf --image-resolution 144dpi // after opendataloader-pdf doc.pdf --image-resolution 144.0
Defensive patterns
Strategy: try-catch
Validate before calling
String raw = commandLine.getOptionValue("image-resolution");
if (raw != null) {
try {
config.setImageResolution(Double.parseDouble(raw.trim()));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("--image-resolution is not a number: " + raw, e);
}
} Type guard
boolean isParsableResolution(String raw) {
try { Double.parseDouble(raw.trim()); return true; }
catch (NumberFormatException e) { return false; }
} Try / catch
try {
double d = Double.parseDouble(raw.trim());
if (!(Double.isFinite(d) && d > 0)) throw new IllegalArgumentException("out of range");
config.setImageResolution(d);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("--image-resolution needs a decimal DPI, got: " + raw, e);
} Prevention
- Strip units (dpi) and use a point decimal separator.
- Validate shell variable expansion is numeric, not empty.
- Catch NumberFormatException separately from the range check to give a clearer message.
When it happens
Trigger: Pass `--image-resolution high`, `--image-resolution dpi`, `--image-resolution 144dpi`, `--image-resolution 1,5` (comma decimal in a locale that expects a point), or an empty-looking token like `--image-resolution .`.
Common situations: Locale confusion (comma vs. point decimal separator); units accidentally appended; a stray character copied from documentation; shell variable expansion yielding an empty string after trim is actually caught here only if non-numeric (blank is parse-failure).
Related errors
- Option --image-resolution requires a finite positive double
- Option --space-ratio requires valid double value.
- Invalid timeout value '%s'. Must be a non-negative integer.
- Option --space-ratio requires a finite positive double value
- Option --threads requires an integer >= 1, got '%s'
AI-assisted analysis of opendataloader-project/opendataloader-pdf@a7789b8e77 (2026-08-14).
Data as JSON: /api/errors/045a10341e77caa8.
Report an issue: GitHub.