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

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.1
File Size Uploaded
pixslim-1.0.1.tar.gz 3.1 kB Details

Built distribution (wheel)

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

Total release size: 6.4 kB

Release files / pixslim-1.0.1.tar.gz

Download URL pixslim-1.0.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aef4a0cf3b760456ba8d990d2e8e429c76b0ad70a376218a06985985af65818e
BLAKE2b-256 checksum
How to use checksums
802cde98f3e91c4f9672e17edafbfb309e1b3611d14565b353e10516b478a016
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.1-py3-none-any.whl

Download URL pixslim-1.0.1-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60a91b82c3e8a0a247805bd8c623eb34e2d273e2241f8db62f08c880538ca3d3
BLAKE2b-256 checksum
How to use checksums
08a362248a081fbdec06990db8f2f42421322efa5cc79557f6fb0f2cbd81dd4a
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

1.0.2

2 release files

This release

1.0.1 This release

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