Skip to main content

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.2

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

Source distribution (sdist)

Source distribution for Pixslim 1.0.2
File Size Uploaded
pixslim-1.0.2.tar.gz 3.1 kB Details

Built distribution (wheel)

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

Total release size: 6.4 kB

Release files / pixslim-1.0.2.tar.gz

Download URL pixslim-1.0.2.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
81903b76247dd9e1ebceb5609081311ab0bc568ea08de5d37686348f907d933a
BLAKE2b-256 checksum
How to use checksums
1daae2b91f335e87d9a6f9b889b904301cfb7a1692cf3faf13fc3dc86e3dcbf0
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.2-py3-none-any.whl

Download URL pixslim-1.0.2-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f2fd0d725b3d8d23ada41f6577ed2f2612f2af7383db4284ec3a961511e84b4
BLAKE2b-256 checksum
How to use checksums
8aff49eaf08fd3c5772f854e4728bc0446e4af44dac0b61b37efaf2d6c45d1be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

1.1.0

2 release files

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

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