pdf-to-jpg-cli
v1.0.2
Published
CLI tool to convert all PDF files in a directory to JPG images
Maintainers
Readme
PDF to JPG CLI
A Node.js command-line tool that converts all PDF files in the current directory to high-quality JPG images with customizable maximum width. Perfect for batch converting PDFs to images for thumbnails, previews, or web use.
Installation
Install globally from npm to use the pdftojpg command anywhere:
npm install -g pdf-to-jpg-cliUsage
After global installation, navigate to any directory containing PDF files and run:
pdftojpg [options]Options
-w, --width <number>- Maximum width in pixels (default: 1275)-h, --help- Show help message
Examples
# Convert all PDFs with default settings (max width: 1275px)
pdftojpg
# Convert with custom max width (800px)
pdftojpg -w 800
# Convert with custom max width (2000px)
pdftojpg --width 2000
# Show help
pdftojpg --helpDevelopment
If you want to contribute or modify this tool:
# Clone the repository
git clone https://github.com/kennedyrose/pdf-to-jpg-cli.git
cd pdf-to-jpg-cli
# Install dependencies
npm install
# Run locally
node index.js -w 1500
# Or install globally from source
npm install -g .Features
- Converts all PDF files in the current directory to JPG format
- High-quality output at 200 DPI
- Maintains original aspect ratio
- Customizable maximum width with automatic height scaling
- Shows conversion progress and final dimensions
- Automatic PDF dimension detection
Requirements
- Node.js
- System dependencies for PDF processing:
- Poppler - Provides
pdfinfocommand to read PDF dimensions and metadata - GraphicsMagick - Image processing library for high-quality PDF to image conversion
- Ghostscript - PostScript and PDF interpreter required by GraphicsMagick for PDF rendering
- Poppler - Provides
Installing System Dependencies
macOS:
brew install poppler graphicsmagick ghostscriptUbuntu/Debian:
sudo apt-get install poppler-utils graphicsmagick ghostscriptWindows:
- Install poppler: Download from http://blog.alivate.com.au/poppler-windows/
- Install GraphicsMagick: http://www.graphicsmagick.org/download.html
- Install Ghostscript: https://www.ghostscript.com/download/gsdnld.html
How It Works
- Scans current directory for PDF files
- Uses
pdfinfoto detect original PDF dimensions - Calculates scaling to fit within specified maximum width
- Converts PDF to JPG using GraphicsMagick with Ghostscript backend
- Outputs high-resolution JPG files with preserved aspect ratios
