Image Redux is a Python script for processing and optimizing images in a specified folder. It resizes images to a maximum width, converts PNG files to JPEG (optional), and can skip small files based on size and width.
-
Clone this repository to your local machine or download the script
redux.py. -
Navigate to the folder containing the script in your terminal.
-
Install the required Python libraries if you haven't already:
# Using pip3 pip3 install pillow pip3 install thumbor-plugins-pngcrush# Debain sudo apt install python3-pillow sudo apt install pngcrush -
Run the script using the following command:
python3 redux.py
You can configure the script by modifying the following variables in redux.py:
folder_path: The path to the folder containing the images you want to process.quality: The quality of the output images (0-100).convert_png_to_jpeg: Set toTrueif you want to convert PNG files to JPEG and then back to PNG for maximum optimization.max_width: The maximum width for resized images.png_crush: Set toTrueif you want to optimize PNG files usingpngcrush.skip_small_files: Set toTrueto skip images that are smaller than a specified size.file_size_limit_mb: The file size limit in megabytes for skipping small files.
The script will process the images in the specified folder and overwrite the old file. After processing, it will provide a summary of the number of images processed, the image quality, maximum width, and skip criteria.
If any images cannot be identified or processed, they will be skipped, and a list of skipped images will be displayed in the summary.
This project is licensed under the MIT License - see the LICENSE file for details.