The most basic command:
python3 securecompress_cli.py --input input.pdf --output output.pdf --size 5This compresses input.pdf to approximately 5MB and saves it as output.pdf.
--input PATH- Input PDF file path--output PATH- Output PDF file path--size MB- Target size in megabytes
-
--dpi DPI- Render DPI (default: 200)- Higher DPI = better quality, larger file
- Recommended: 150-250
- Example:
--dpi 200
-
--mode MODE- Color mode (default: color)color- Full color (RGB)gray- Grayscalebw- Black and white (smallest size)- Example:
--mode gray
-
--max-passes N- Maximum compression passes (default: 2)- More passes = better size accuracy, longer time
- Example:
--max-passes 3
-
--engine ENGINE- Compression engine (default: auto)auto- Automatically choose best engineobject- Object-level compression (best for text)raster- Raster-based compression (best for images)- Example:
--engine object
-
--content-type TYPE- Content type hint (default: unknown)text- Text-heavy documentsscan- Scanned documentsunknown- Mixed or unknown content- Example:
--content-type text
-
--adaptive- Use adaptive per-page compression targets- Allocates more space to complex pages
- Example:
--adaptive
-
--quality-check- Enable quality sampling- Monitors compression quality using SSIM
- Example:
--quality-check
-
--quality-threshold FLOAT- SSIM quality threshold (default: 0.82)- Range: 0.0 to 1.0 (higher = better quality)
- Example:
--quality-threshold 0.85
--log PATH- Log file path- Example:
--log compression.log
- Example:
python3 securecompress_cli.py \
--input document.pdf \
--output document_email.pdf \
--size 9python3 securecompress_cli.py \
--input document.pdf \
--output document_web.pdf \
--size 4.5 \
--dpi 150python3 securecompress_cli.py \
--input report.pdf \
--output report_compressed.pdf \
--size 5 \
--mode gray \
--engine object \
--content-type textpython3 securecompress_cli.py \
--input scan.pdf \
--output scan_compressed.pdf \
--size 2 \
--mode bw \
--dpi 150 \
--content-type scanpython3 securecompress_cli.py \
--input photos.pdf \
--output photos_compressed.pdf \
--size 10 \
--dpi 200 \
--mode color \
--adaptive \
--quality-checkpython3 securecompress_cli.py \
--input large.pdf \
--output tiny.pdf \
--size 1 \
--dpi 120 \
--mode gray \
--max-passes 4The CLI outputs JSON-formatted progress and status messages to stdout:
{"type": "status", "message": "Initializing...", "step": "init"}
{"type": "progress", "current": 1, "total": 10, "percent": 10, "message": "Processing page 1/10"}
{"type": "complete", "output_path": "output.pdf", "final_size_mb": 4.87, "percent": 100}
{"type": "summary", "input_size_mb": 25.3, "final_size_mb": 4.87, "total_pages": 10, ...}This makes it easy to integrate into other applications and monitor progress.
- Use
--mode grayto reduce size without losing readability - Use
--engine objectfor better text quality - Use
--content-type textto optimize for text
- Use
--mode bwfor black and white scans - Use lower DPI (120-150) for acceptable quality
- Use
--content-type scan
- Use
--adaptiveto allocate space intelligently - Use
--quality-checkto maintain quality - Use
--max-passes 3for better size accuracy
- Use higher DPI (200-250)
- Use
--quality-check --quality-threshold 0.85 - Use
--adaptivefor complex documents
- Use
--mode bwor--mode gray - Use lower DPI (100-150)
- Use
--max-passes 4 - Accept that quality will be reduced
SECURECOMPRESS_LOG_PATH- Default log file pathexport SECURECOMPRESS_LOG_PATH="/tmp/compression.log" python3 securecompress_cli.py --input in.pdf --output out.pdf --size 5
0- Success1- General error (file not found, compression failed, etc.)130- Cancelled by user (Ctrl+C)
- DPI: Higher DPI = longer processing time
- Passes: More passes = longer processing time
- Adaptive: Adds ~10-20% processing time
- Quality Check: Adds ~5-10% processing time
Typical processing times (on modern hardware):
- 10-page document: 10-30 seconds
- 50-page document: 1-3 minutes
- 100-page document: 3-6 minutes
- Free Version Limits: 25MB input, 20 pages maximum
- Memory: Large PDFs may require significant RAM
- Poppler Required: Must have Poppler installed
- PDF Features: Some advanced PDF features may be lost (forms, annotations, etc.)
The free CLI version provides core compression functionality. For advanced features like:
- Drag-and-drop interface
- Batch processing with queue management
- Preset configurations
- No file size/page limits
- Priority support
Check out QuantPDF Pro (GUI version): https://quantpdf.com