Metadata-Version: 2.5
Name: tlcompression
Version: 0.1.0
Summary: Extreme image compression library, with extreme loss
Project-URL: Homepage, https://github.com/pallandos/total-loss-compression-py
Project-URL: Issues, https://github.com/pallandos/total-loss-compression-py/issues
Author-email: Pallandos <contact@pallandos.dev>
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Requires-Dist: google-genai
Requires-Dist: pillow>=10.2.0
Description-Content-Type: text/markdown

# 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](./doc/imgs/lenna.png)

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](./doc/imgs/lenna_unzipped.jpeg)


Pretty good :)

## Usage

```py
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)
```