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.1.0.tar.gz (3.4 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.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for deflato-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2779c4a7ad6329b9ab320da21d5ffa2a05a3673713dd2975baf7cc10293f62e4
MD5 539428bf820902a263fd72d4a8a8aae8
BLAKE2b-256 445dd0e490ae3b7dc6f8a1ab8bc15a0779bf1eeef1f1b2cd89043c791248b630

See more details on using hashes here.

File details

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

File metadata

  • Download URL: deflato-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5022f4cbae46b52a7f98f7d501ba316bbd82e7397c09c01d4da1e0a0139bd3bc
MD5 e9e2965ab472a531057c08678fa4047f
BLAKE2b-256 a276e2a5d0aedfc553814a8597a1e533bf122d34cf959f53549de79be4b36683

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