Skip to main content

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 < 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docshrink_samarth-1.0.0.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docshrink_samarth-1.0.0-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file docshrink_samarth-1.0.0.tar.gz.

File metadata

  • Download URL: docshrink_samarth-1.0.0.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.7

File hashes

Hashes for docshrink_samarth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c66045b5d8ee5a1a811e402aac4b289c60130f9e9c1ddea7fc4f8d1ce4b8c731
MD5 cad35c448da0695444e084b417056384
BLAKE2b-256 455a9c8050e237a7b4c9ec5ad4ee1da6fdc0c0cdcac3d033513bc38cec9f4bbe

See more details on using hashes here.

File details

Details for the file docshrink_samarth-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docshrink_samarth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73fb3fce32fe90257786352dd32fa718b9c24705c878e71a824aae73562c7478
MD5 8b049df8a80d4a9f970d48b0e36b98fa
BLAKE2b-256 c31160332d4301a987246ece68a27b51a9eb4a8d16e26b29e08f37c1301af262

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page