Skip to main content

Deflato — compress images with one line of code

Project description

Deflato Python SDK

Compress images with one line of code. Powered by deflato.com.

Install

pip install deflato

Quick Start

from deflato import Deflato

client = Deflato("your-api-key")

# Compress a single image
result = client.compress("photo.jpg", format="WEBP", quality=75)
print(f"Saved {result.savings_percent}% → {result.output_path}")

# Get info without saving
info = client.info("photo.jpg", format="AVIF")
print(f"{info.input_size:,}{info.output_size:,} bytes ({info.savings_percent}% savings)")

# Batch compress
results = client.compress_batch(
    ["img1.jpg", "img2.png", "img3.heic"],
    output_dir="./compressed",
    format="WEBP",
    quality=80,
)
for r in results:
    print(f"{r.output_path}: {r.savings_percent}%")

API

Deflato(api_key, base_url="https://deflato.com")

client.compress(input_path, output=None, quality=80, max_dimension=0, format="JPEG", strip_exif=True)

Returns CompressResult:

  • success: bool
  • input_size: int (bytes)
  • output_size: int (bytes)
  • savings_percent: int
  • output_path: str
  • output_format: str

client.info(input_path, quality=80, format="JPEG")

Same as compress but doesn't save — returns size/dimension info.

client.compress_batch(input_paths, output_dir=None, quality=80, format="JPEG")

Compress multiple files. Returns list of CompressResult.

Supported Formats

Input: JPEG, PNG, WEBP, HEIC, TIFF, BMP, GIF, RAW (CR2, NEF, ARW, DNG)

Output: JPEG, PNG, WEBP, AVIF

Get API Key

  1. Sign up at deflato.com
  2. Activate Pro (or use promo code)
  3. Go to Account → Generate API Key

License

MIT

Project details


Download files

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

Source Distribution

deflato-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

deflato-1.0.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deflato-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for deflato-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1e2464563e8aa3e75e845a20f84180e598a9b21aaae2098e86a8f238675aa774
MD5 893ed43b661987c1a3d4356851552550
BLAKE2b-256 7a655c59169316883611888e31b98999124dc30daa1499f6c3bb5e9610b1f881

See more details on using hashes here.

File details

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

File metadata

  • Download URL: deflato-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for deflato-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b589992137abd0e36a2a4eec90dcfa31480e3e154a15ac972b3b0d0f62f37835
MD5 1db893ba14ecffeda898ae15c2f37b72
BLAKE2b-256 947c729b36d780c73cde7c01992c30ebb3429408e4307391c5b2d6b35d561801

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