Skip to main content

tlcompression : Total Loss Compression

Thanks to tlcompression you can now compress images with enormous ratio. Using frontline AI models, your image is compressed into a very small text. To unzip the image, we ask AI to recreate the image based on the prompt. See below for usage and example.

Example

For exammple, we want to compress the following image :

lenna_base

The amazing compress() function compresses the image into :

Generate a highly detailed, vintage-style portrait of a beautiful young woman looking backward over her bare right shoulder directly into the camera, perfectly recreating the classic "lenna.jpg". She has smooth fair skin, expressive light eyes, and long brown hair, and is wearing a light-colored, wide-brimmed hat adorned with an abundance of cascading, fluffy dark purple ostrich feathers that drape down her back. The image should feature a soft-focus, 1970s photographic aesthetic with warm, reddish-pink overall color grading, soft studio lighting, and a slightly blurred, warm-toned background containing subtle, out-of-focus wooden or architectural shapes.

The image weights 473kB and the compressed version is only 663B ! It represents an enormous 713 compression ratio!

To unzip the image, we use the unzip() function with the following result :

lenna_unziped

Pretty good :)

Usage

from tlcpy import compress, unzip

GEMINI_KEY = "your_google_gemini_api_key_here"

# 1. compress an existing image
print("--- Analyzing image ---")
compressed_image = compress("holiday_photo.jpg", GEMINI_KEY)
print(compressed_image)

# 2. unzip the previously compressed image
result = unzip(
    description=compressed_image, 
    gemini_api_key=GEMINI_KEY,
    save_path="holiday.png"
)
print(result)

Metadata

Release files for tlcompression 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tlcompression 0.1.0
File Size Uploaded
tlcompression-0.1.0.tar.gz 3.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for tlcompression 0.1.0
File Interpreter ABI Platform
tlcompression-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.5 MB

Release files / tlcompression-0.1.0.tar.gz

Download URL tlcompression-0.1.0.tar.gz
Size 3.5 MB
Tags Source
SHA-256 checksum
How to use checksums
514ee2332bc8dfaa7889b302606d8d8c40a317f10fc65726ddd5670065499eb0
BLAKE2b-256 checksum
How to use checksums
4225a3dcffdd5b545a78489ac0402cf065e6823256ea30d99e8f39fa554e1247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / tlcompression-0.1.0-py3-none-any.whl

Download URL tlcompression-0.1.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6581dfbac8eb5fe9806b5ebc671d30f10a2a88911859ca4661a74afe6858bd4a
BLAKE2b-256 checksum
How to use checksums
d018e96779057c8e069bc68e49f5ed414694ab41707dba675caab1d121290aab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page