Python Bulk Image Compressor
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.
Key Features
- 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.
Installation
From PyPI
pip install py-bulk-image-compressor
Requires Python 3.10+
From Source
- 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
Usage
After installation, you can run:
py-bulk-image-compressor -h
Example Commands
-
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:
Command-Line Options
| 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). |
Logging
- Generates or appends to a
logs.txtfile in your current working directory. - The
configurations.inifile controls log settings (e.g.,max_rows).
Contributing
- 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.
License
This project is licensed under the MIT License.
Questions or Issues?
- Open an issue on GitHub
- Contributions, suggestions, and bug reports are welcome!
Support
If you find this tool helpful, consider supporting:
Your support helps me continue to create and maintain useful projects.
Updates
10/11/2026
- Security update: now requires Pillow 13 and pillow-heif 1.3, which fix a long list of known vulnerabilities in image parsing. Upgrade with
pip install -U py-bulk-image-compressor. - Releases are now published to PyPI from GitHub releases.
13/04/2025
- 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.
27/01/2025
- Deployed to pypi, installation:
pip install py-bulk-image-compressor
usage:py-bulk-image-compressor -h
26/01/2025
- 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
02/12/2023
- Automatic detection and handling of RGB/RGBA channels.
- Thanks to "ZenithVal" for the suggestion.
06/04/2023
- Updated
README.md. - Updated
requirements.txtwith the latest package versions.
12/12/2022
- Introduced a
resourcesfolder containingconfigurations.inifor storing program settings. - Set up future GUI plans using
customtkinter. - Removed PySimpleGUI from dependencies.
06/12/2022
- 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.
05/12/2022
- Added support for
.heifand.heicformats (e.g., iPhone photos). - Updated
requirements.txtto includepillow-heif.
04/12/2022
- 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.
Metadata
Release files for py-bulk-image-compressor 1.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_bulk_image_compressor-1.0.9.tar.gz | 15.5 kB | Without provenance | Details for py_bulk_image_compressor-1.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_bulk_image_compressor-1.0.9-py3-none-any.whl | Python 3 | none | any | Details for py_bulk_image_compressor-1.0.9-py3-none-any.whl |
Total release size: 32.3 kB
Release files / py_bulk_image_compressor-1.0.9.tar.gz
| Download URL | py_bulk_image_compressor-1.0.9.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49d4ccec2b2eaa88c3ee72c15f4c1e6c3c271de3b25bf61f0d882a1de4cace85
|
|
BLAKE2b-256 checksum How to use checksums |
79e38fb66ac0f7dde758e49531be55ab8ebeabf93b60cb7889f75120bc93521e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / py_bulk_image_compressor-1.0.9-py3-none-any.whl
| Download URL | py_bulk_image_compressor-1.0.9-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34dcbd27dc4c131b7e5e1bb22fba46d9136eb5010fa32c412d9844c0754d0fdc
|
|
BLAKE2b-256 checksum How to use checksums |
a813c8b6fb001e8a5b3fdb601b848a97b24072a045790af1d2a806a83ff26202
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for py-bulk-image-compressor 1.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.