Script to reduce the size of JPEG image files.
Algorithm source from this Yelp blog: https://engineeringblog.yelp.com/2017/06/making-photos-smaller.html
- Reducing image quality:
- Fixed quality chosen by the user.
- Dynamic quality. Selected per image using the SSIM algorithm that try to mimic the human vision system to select the best quality where humans will not be able to appreciate the difference between original and modified image.
- Execute:
pip install -r requirements.txt
- Look at script options:
python main.py -h
- Execute it:
python main.py [IMAGES_FOLDER] [--ANOTHER_OPTIONS]
You can create an isolated Python environment to install required libraries with virtualenv:
- Create a virtualenv:
python -m venv [VENV_FOLDER]
- Activate virtualenv:
source [VENV_FOLDER]/bin/activate
Original image metadata will be copied to the new modified image:
- EXIF. All the original EXIF tags
- FILE dates. Access and modification dates.
Non-JPEG images will be copied to the destination folder without being modified
That image will be copied to the failures
folder so that you can analyze why later