PixSlim
PixSlim is a lightweight and easy-to-use Python package for compressing JPG, JPEG, and PNG images while trying to reach a target file size.
✨ Features
- 📦 Compress JPG, JPEG, and PNG images
- 🎯 Target file size in KB
- 🖼️ Automatically reduces image dimensions if needed
- ⚡ Simple and beginner-friendly API
- 🐍 Built with Pillow
Installation
pip install pixslim
Requirements
- Python 3.9+
- Pillow
Usage
from pixslim import Compressor
compressor = Compressor(target_kb=500)
result = compressor.compress(
"photo.png",
"photo_small.png"
)
print(result)
Example output:
{
"original_kb": 1356.42,
"final_kb": 492.18,
"reduction_percent": 63.71,
"quality": None,
"size": (1920, 1080)
}
Supported Formats
| Input | Output |
|---|---|
| JPG | JPG |
| JPEG | JPEG |
| PNG | PNG |
Parameters
Compressor(target_kb=500)
| Parameter | Type | Description |
|---|---|---|
| target_kb | int | Desired maximum file size in KB |
compress(input_file, output_file)
| Parameter | Type | Description |
|---|---|---|
| input_file | str | Input image path |
| output_file | str | Output image path |
Example
from pixslim import Compressor
compressor = Compressor(target_kb=300)
compressor.compress(
"image.jpg",
"image_small.jpg"
)
License
This project is licensed under the MIT License.
##Author
Fatemeh SHM
Release files for Pixslim 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pixslim-1.0.0.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pixslim-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / pixslim-1.0.0.tar.gz
| Download URL | pixslim-1.0.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6bbe8bfe23978e26ecf78c0f842549cc9dc526e7214c07297f73bad09579c337
|
|
BLAKE2b-256 checksum How to use checksums |
7fdd6040f08d39d8eb8fde74544d5fd1f07a03c178b597a0f6ff1fdd15a23bd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / pixslim-1.0.0-py3-none-any.whl
| Download URL | pixslim-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0127f62f40763979bf2847e2957266e13db57f35e0443fdb5ca3de666e6bc87b
|
|
BLAKE2b-256 checksum How to use checksums |
89a441e0a36fe5dcfc608146d21b07db9b86fed212acf29ab3ea7d2095dd1969
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|