py-bulk-image-compressor is a user-friendly CLI tool for compressing and resizing images in bulk. It offers extensive options for managing image quality, format, and metadata while maintaining fast, efficient performance.
- Supports Multiple Formats: JPEG, PNG, WEBP, AVIF, HEIF, and more.
- Metadata Handling: Choose whether to preserve or remove EXIF data.
- Multicore Processing: Utilizes all available CPU cores.
- Flexible Settings: Customize output quality, max width, and destination directory.
pip install py-bulk-image-compressorRequires Python 3.10+
- Clone the repository:
git clone https://github.com/georgekhananaev/py-image-compressor.git cd py-image-compressor - Install dependencies:
pip install -r requirements.txt
- Install locally:
pip install . - Run the CLI:
py-bulk-image-compressor -h
After installation, you can run:
py-bulk-image-compressor -h-
Basic compression and resize:
py-bulk-image-compressor -l "path/to/original_images" -d "path/to/output"
Uses default format (
jpeg), quality=80, max_width=1920px. -
Specific format and quality:
py-bulk-image-compressor -l "path/to/original_images" \ -d "path/to/output" -f webp -w 800 -q 70
-
Remove metadata & skip larger compressed files:
py-bulk-image-compressor -l "path/to/original_images" \ -d "path/to/output" -rm y -r y
Logs are saved to logs.txt in the current cmd/terminal working directory. Installation & Usage screenshot below:
| Option | Required | Default Value | Description |
|---|---|---|---|
-l |
Yes | (No Default) | Input directory for original images. (Example: -l "C:/images/") |
-d |
No | /data/output/ |
Output directory for compressed images. |
-f |
No | jpeg |
Output format (e.g., webp, png, avif). |
-w |
No | 1920 |
Maximum width (px). |
-q |
No | 80 |
Image quality (0-100). |
-r |
No | n (off) |
Remove compressed if it’s larger than the original (-r y). |
-rm |
No | n (off) |
Remove all metadata (-rm y). |
- Generates or appends to a
logs.txtfile in your current working directory. - The
configurations.inifile controls log settings (e.g.,max_rows).
- Fork the repository.
- Create a new branch:
git checkout -b feature-name. - Commit your changes:
git commit -m "Add awesome feature". - Push to your branch:
git push origin feature-name. - Open a pull request on GitHub.
This project is licensed under the MIT License.
- Open an issue on GitHub
- Contributions, suggestions, and bug reports are welcome!
If you find this tool helpful, consider supporting:
Your support helps me continue to create and maintain useful projects.
- Added JPEG normalization step to ensure consistent color‑space conversion and correct chroma placement.
- Upgraded compressor to use progressive encoding, optimized Huffman tables, and 4:2:0 subsampling by default for smaller output sizes.
- Added official support for Python 3.13.x.
- Deployed to pypi, installation:
usage:
pip install py-bulk-image-compressor
py-bulk-image-compressor -h
- EXIF metadata is preserved if supported by the output format (e.g., JPEG).
- Added support for
.avifformat (requirespillow-avif-plugin). - Minor speed optimizations for faster compression.
- Updated
requirements.txtwith the latest package versions. - Added logs, which is exported to logs.txt
- Added tests, use
pytest --maxfail=1 --disable-warnings -v
- Automatic detection and handling of RGB/RGBA channels.
- Thanks to "ZenithVal" for the suggestion.
- Updated
README.md. - Updated
requirements.txtwith the latest package versions.
- Introduced a
resourcesfolder containingconfigurations.inifor storing program settings. - Set up future GUI plans using
customtkinter. - Removed PySimpleGUI from dependencies.
- Default values added for
-d,-f, and-qoptions. You can run:Defaults: JPEG format, 80% quality, 1920px max width,python main.py -l "C:/Your Folder/"/data/output/as the destination folder. - Simplified the code using
*argsand**kwargs.
- Added support for
.heifand.heicformats (e.g., iPhone photos). - Updated
requirements.txtto includepillow-heif.
- Improved the output to display the actual size saved for each image, with full multithreading conversion support.
- Enhanced terminal output for better visualization of size savings.
- Began GUI development for Windows and Ubuntu.
- Added
-r yto skip retaining larger compressed images.


