This project provides a simple Python script for lossless compression of images in a specified directory while preserving metadata. It utilizes the Pillow library for image processing and relies on Python 3.9 or higher.
- Ensure you have Python 3.9 installed on your system. If not, you can download and install it from the official Python website: Python Downloads.
- Clone or download the project repository to your local machine.
- Navigate to the project directory using the command line or terminal.
- Install the required dependencies by running the following command:
pip3 install -r requirements.txt
- Once the dependencies are installed, you can run the project by executing the main script
main.py
with Python 3.9. Use the following command:python main.py
- Follow the on-screen prompts to provide the path to the directory containing images you want to compress, specify the compression quality, and choose whether to replace original files with compressed ones.
- The script will process the images in the specified directory, compress them, and provide feedback on the compression process.
- After completion, you will receive a message indicating that the image compression is completed.
- The script supports various image formats such as PNG, JPEG, JPG, and BMP.
- It preserves the creation and modification dates of the original images.
- Image orientation is corrected automatically based on EXIF metadata.
- You can adjust the compression quality from 0 to 100, where 100 indicates the best quality.
- Original files can be replaced with the compressed ones or kept separately based on user preference.
Feel free to explore and modify the script according to your requirements!