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.
- Novel Algorithms: Uses custom-designed APQM (Advanced Perceptual Quality Model), CCT (Cascade Compression Tournament), POSD (Perceptual Object Stream Deduplication), and EADS (Entropy-Aware Deflate Strategy) algorithms.
- MPTSS (Multi-Phase Target Size Solver): Need an output file to be exactly
< 5MBfor an email attachment? Just specify--target-size 5MBand 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, orarchive.--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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docshrink_samarth-1.0.2.tar.gz.
File metadata
- Download URL: docshrink_samarth-1.0.2.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
099368af1156309ae17db8d656dafd812d6b7e3d1c8d25aceac8126153d09017
|
|
| MD5 |
a7dd7049bee8448218751aef080c5792
|
|
| BLAKE2b-256 |
34ff0f8dd0434be7b9edd17a59434272cfeb8daa14c1a73fec3705ba88ef229b
|
Provenance
The following attestation bundles were made for docshrink_samarth-1.0.2.tar.gz:
Publisher:
release.yml on SamarthAgrawal-002/ShrinkIt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docshrink_samarth-1.0.2.tar.gz -
Subject digest:
099368af1156309ae17db8d656dafd812d6b7e3d1c8d25aceac8126153d09017 - Sigstore transparency entry: 2299439241
- Sigstore integration time:
-
Permalink:
SamarthAgrawal-002/ShrinkIt@55106341cb6997787f751c115f6033ade299e252 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/SamarthAgrawal-002
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55106341cb6997787f751c115f6033ade299e252 -
Trigger Event:
push
-
Statement type:
File details
Details for the file docshrink_samarth-1.0.2-py3-none-any.whl.
File metadata
- Download URL: docshrink_samarth-1.0.2-py3-none-any.whl
- Upload date:
- Size: 49.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65a50ec77ddf11c53773d5864ee766aee5baaad3128ead203ff61556da13fea1
|
|
| MD5 |
ebf0818c8339c075db120fe9327f6a2c
|
|
| BLAKE2b-256 |
33d280aecb81066ee02293251bdb6646ec0fb1c55a758b44176ab4d2929952fa
|
Provenance
The following attestation bundles were made for docshrink_samarth-1.0.2-py3-none-any.whl:
Publisher:
release.yml on SamarthAgrawal-002/ShrinkIt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docshrink_samarth-1.0.2-py3-none-any.whl -
Subject digest:
65a50ec77ddf11c53773d5864ee766aee5baaad3128ead203ff61556da13fea1 - Sigstore transparency entry: 2299439245
- Sigstore integration time:
-
Permalink:
SamarthAgrawal-002/ShrinkIt@55106341cb6997787f751c115f6033ade299e252 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/SamarthAgrawal-002
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55106341cb6997787f751c115f6033ade299e252 -
Trigger Event:
push
-
Statement type: