An open API service indexing awesome lists of open source software.

https://github.com/angelhtml/image_compress


https://github.com/angelhtml/image_compress

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

How to Use This Script:
Install Pillow if you haven't: pip install pillow

Set the paths:

Replace "path/to/your/source/folder" with your source folder containing images

Replace "path/to/your/destination/folder" with where you want compressed images saved

Adjust settings (optional):

JPEG_QUALITY: 85 is good, lower for more compression

WEBP_QUALITY: 80 is good, lower for more compression

MAX_SIZE: Set maximum dimension (width/height) or None to keep original size

Run the script: python image_compressor.py

What It Does:
Reads all supported image files from the source folder

For each image:

Converts to RGB if needed (for JPEG compatibility)

Resizes if MAX_SIZE is specified

Creates three compressed versions:

JPEG with quality optimization

PNG with optimization

WebP (usually the best compression)

Saves all compressed versions to the destination folder

Preserves original filenames but adds suffixes (_compressed.jpg, _optimized.png, etc.)

Handles errors gracefully and reports progress

Supported Image Formats:
The script handles JPG, JPEG, PNG, WebP, BMP, and GIF files. You can modify the SUPPORTED_EXTENSIONS tuple if needed.