ShrinkIt is a high-performance offline document compression utility designed to reduce file sizes of PDFs, images (including PNG, JPEG, TIFF, BMP, and WebP), and other formats without compromising quality. It operates entirely locally on your machine, ensuring privacy and efficiency.
Key Features:
Format Agnostic Compression: Seamlessly compresses a wide range of document and image types.
Custom Algorithms: Employs advanced techniques like APQM (Advanced Perceptual Quality Model) and CCT (Cascade Compression Tournament) for superior results.
Target Size Solver (MPTSS): Automatically adjusts compression to meet specific file size requirements, such as reducing files to fit email limits.
Privacy-Focused Processing: Ensures all operations are conducted locally with no data uploaded or shared.
WinGet Installation: Easily deploy ShrinkIt using the Windows Package Manager with commands like winget install ShrinkIt.
Target Audience and Benefits:
Ideal for developers, businesses, and individuals who need efficient document management. It helps reduce storage costs, improve email deliverability, and streamline workflows by ensuring files meet size requirements without quality loss.
ShrinkIt is a reliable tool for anyone looking to optimize their digital documents efficiently and securely, with seamless integration into automated pipelines or simple one-click operations.
README
DocShrink
DocShrink is a high-performance, offline, and cross-platform document and image compression engine. It runs entirely locally on your machine—no cloud services, no APIs, and no internet required. It is built for integration into automated pipelines and handles batch processing effortlessly.
Key Features
Format Agnostic: Compresses PDF, JPEG, PNG, WebP, TIFF, and BMP seamlessly.
MPTSS (Multi-Phase Target Size Solver): Need an output file to be exactly < 5MB for an email attachment? Just specify --target-size 5MB and DocShrink will find the optimal balance of quality and scale to hit the target.
Privacy First: 100% local processing. No data is ever uploaded.
Installation
pip install -e .
Usage (CLI)
DocShrink provides a simple yet powerful CLI for individual files and batch processing.
# Compress a single file
docshrink input.pdf output.pdf
# Compress a file using a built-in preset
docshrink input.jpg output.jpg --preset web
# Compress an entire directory of images and PDFs
docshrink ./my_documents ./compressed_documents
# Compress a directory to a specific target size (per file)
docshrink ./large_scans ./compressed_scans --target-size 2MB
# Strip all metadata during compression
docshrink document.pdf output.pdf --remove-metadata
# Convert to grayscale and downsample large images
docshrink large_photo.tiff output.jpg --grayscale --max-resolution 1920
CLI Options
--lossless: Enforce lossless compression (no visual degradation).
--lossy: Allow aggressive lossy recompression for maximum size reduction.
--preset: Use a tuned profile: screen, ebook, print, or archive.
--target-size: Attempt to compress the file to match the specified size (e.g. 2MB, 500KB).
--max-resolution: Downsample images so the longest side doesn't exceed this pixel value.
--grayscale: Convert images and documents to grayscale.
--remove-metadata: Strip EXIF, XMP, and PDF metadata for maximum privacy and size reduction.
--dry-run: Evaluate what savings would be achieved without actually writing the files.
--json-log: Output a detailed JSON report of the batch process.
Architecture
Please see the docs/ folder for deep dives into the underlying systems:
docs/architecture.md: Overall system design and module boundaries.
docs/algorithms.md: Explanation of APQM, CCT, POSD, and MPTSS.
docs/pdf_internals.md: How the PDF engine dissects and compresses streams.