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: boolinput_size: int(bytes)output_size: int(bytes)savings_percent: intoutput_path: stroutput_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
- Sign up at deflato.com
- Activate Pro (or use promo code)
- 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
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 deflato-1.2.0.tar.gz.
File metadata
- Download URL: deflato-1.2.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d524ce23c833ab771b385fdc9520e6055e50365bfd20494b050f59f80cd0b4ab
|
|
| MD5 |
fa1b77127e40ab9cdf9270855eddbfd7
|
|
| BLAKE2b-256 |
08e19905a88e365f2e92b6cfd8fa2f61274cadf8b2b8238504d1802210c57982
|
File details
Details for the file deflato-1.2.0-py3-none-any.whl.
File metadata
- Download URL: deflato-1.2.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4a734d21f6d6fefa273800264336cb9889cbe70f48d3e0a6ce5de95097eb5af
|
|
| MD5 |
c91c6714647162b902a2cf0e27848c6d
|
|
| BLAKE2b-256 |
383db7f831ca81d3a76fb2e37515b220e5baa17a0a4d0d8362290af292b0edc8
|