Description:
Currently, pdf2image-cli only supports controlling output image resolution via the --dpi flag. This works, but it's an indirect way to size images — for many automation and pipeline use cases (thumbnails, fixed-size previews, feeding images into a downstream model with fixed input dimensions, etc.), it would be much simpler to specify the exact pixel dimensions directly.
Proposal
Add two new CLI options:
--width <PIXELS> — target output image width in pixels
--height <PIXELS> — target output image height in pixels
Suggested behavior
- If both
--width and --height are provided, resize/render the page to exactly those dimensions.
- If only one of the two is provided, the other should be computed automatically to preserve the page's aspect ratio.
- If neither is provided, fall back to the current
--dpi-based behavior (no breaking change).
- If
--width/--height are used together with --dpi, either the explicit dimensions should take precedence, or the tool should return a clear validation error explaining that the two options are mutually exclusive (whichever the maintainer prefers — happy to open a PR either way).
Example usage
pdf2images --input Fuzzy.pdf --output-dir images --width 1024 --height 768 --format png
# aspect-ratio preserved, height auto-computed
pdf2images --input Fuzzy.pdf --output-dir images --width 800 --format png
Motivation
- More intuitive for users who think in pixels rather than DPI.
- Useful for generating consistently-sized thumbnails/previews across PDFs with different page sizes.
- Keeps the tool convenient for downstream pipelines that expect a known image resolution.
Description:
Currently,
pdf2image-clionly supports controlling output image resolution via the--dpiflag. This works, but it's an indirect way to size images — for many automation and pipeline use cases (thumbnails, fixed-size previews, feeding images into a downstream model with fixed input dimensions, etc.), it would be much simpler to specify the exact pixel dimensions directly.Proposal
Add two new CLI options:
--width <PIXELS>— target output image width in pixels--height <PIXELS>— target output image height in pixelsSuggested behavior
--widthand--heightare provided, resize/render the page to exactly those dimensions.--dpi-based behavior (no breaking change).--width/--heightare used together with--dpi, either the explicit dimensions should take precedence, or the tool should return a clear validation error explaining that the two options are mutually exclusive (whichever the maintainer prefers — happy to open a PR either way).Example usage
# aspect-ratio preserved, height auto-computed pdf2images --input Fuzzy.pdf --output-dir images --width 800 --format pngMotivation