π― Target-size PDF compression from the command line
Compress PDFs to an exact target size, locally and privately.
Features β’ Installation β’ Quick Start β’ Documentation β’ GUI Version
Most PDF compression tools offer vague "Low/Medium/High" quality settings. QuantPDF CLI is different:
- π― Target-Oriented: Specify exact output size (e.g., "compress to 25MB")
- π Privacy-First: 100% local processing, no uploads, no cloud
- π Smart Optimization: Prioritizes text readability over aggressive downsizing
- β‘ Fast & Efficient: Optimized for large scanned PDFs
- π Free & Open Source: MIT License, use anywhere
- β Exact target size - Set 25MB, get 25MB (Β±5% accuracy)
- β Local processing - Files never leave your machine
- β Smart compression - Maintains readability while reducing size
- β Multiple passes - Iterative optimization for better results
- β Flexible DPI - Choose from 100-300 DPI
- β Color modes - Color, Grayscale, or Black & White
- β Progress tracking - Real-time JSON progress output
- β Batch processing - Process multiple files via scripting
- π Government forms with strict size limits (10-25MB)
- π Academic submissions and applications
- πΌ Job applications with resume size caps
- π Archiving large scanned documents
- π§ Email attachments with size restrictions
pip install quantpdf-cligit clone https://github.com/paradoxie/quantpdf-cli.git
cd quantpdf-cli
pip install -r requirements.txt- Python: 3.8 or higher
- Poppler: Required for PDF processing
macOS:
brew install popplerUbuntu/Debian:
sudo apt-get install poppler-utilsWindows: Download from Poppler for Windows
# Compress to 25MB
quantpdf input.pdf output.pdf --size 25
# Compress to 10MB with 150 DPI
quantpdf input.pdf output.pdf --size 10 --dpi 150
# Compress to grayscale
quantpdf input.pdf output.pdf --size 20 --mode grayscale# Maximum quality with 3 optimization passes
quantpdf input.pdf output.pdf --size 25 --dpi 300 --max-passes 3
# Black & white for text documents
quantpdf input.pdf output.pdf --size 5 --mode bw --dpi 200
# With progress logging
quantpdf input.pdf output.pdf --size 25 --log compression.logusage: quantpdf [-h] --input INPUT --output OUTPUT --size SIZE
[--dpi DPI] [--mode {color,grayscale,bw}]
[--max-passes PASSES] [--log LOG]
Required arguments:
--input INPUT Input PDF file path
--output OUTPUT Output PDF file path
--size SIZE Target size in MB (e.g., 25 for 25MB)
Optional arguments:
--dpi DPI DPI for images (100-300, default: 200)
--mode MODE Color mode: color, grayscale, bw (default: color)
--max-passes PASSES Max optimization passes (1-3, default: 2)
--log LOG Log file path for debugging
-h, --help Show this help message
- Installation Guide - Detailed installation instructions
- Usage Guide - Complete usage examples
- API Documentation - Python API reference
- Troubleshooting - Common issues and solutions
- Compression Strategy - How compression works
- Protocol Documentation - CLI protocol specification
- Packaging Guide - Building and distribution
# Compress resume to meet 10MB limit
quantpdf resume_scanned.pdf resume_compressed.pdf --size 10 --dpi 200# Process all PDFs in a directory
for file in *.pdf; do
quantpdf "$file" "compressed_$file" --size 25
doneimport subprocess
import json
def compress_pdf(input_path, output_path, target_mb):
"""Compress PDF with progress tracking"""
process = subprocess.Popen(
['quantpdf', input_path, output_path, '--size', str(target_mb)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
for line in process.stdout:
event = json.loads(line)
if event['type'] == 'progress':
print(f"Progress: {event['percent']}%")
elif event['type'] == 'complete':
print(f"Done! Final size: {event['finalSizeMb']}MB")
return process.wait()
# Usage
compress_pdf('input.pdf', 'output.pdf', 25)See more examples in the examples/ directory.
Want a simpler, visual experience?
QuantPDF is also available as a native macOS app with:
- π±οΈ Drag-and-drop interface
- ποΈ Real-time preview
- π¦ Batch processing queue
- πΎ Custom presets
- π Compression history
- π Automatic updates
Download QuantPDF for macOS β
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Fork and clone the repo
git clone https://github.com/paradoxie/quantpdf-cli.git
cd quantpdf-cli
# Install development dependencies
pip install -r requirements.txt
pip install pytest black flake8
# Run tests
pytest tests/
# Format code
black quantpdf_cli.py
# Submit a pull requestThis project is licensed under the MIT License - see the LICENSE file for details.
- Built with Pillow for image processing
- Uses pdf2image for PDF conversion
- Powered by Poppler for PDF rendering
- π Bug reports: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π§ Email: support@quantpdf.com
- π Website: quantpdf.com
If you find this project useful, please consider giving it a star! β
Made with β€οΈ by the QuantPDF team
Website β’ GUI Version β’ Documentation