This script processes images in a directory, applying format conversion, resizing, and compression.
- Python 3.6+
- Pillow library
-
Clone this repository:
git clone https://github.com/yourusername/image-processing-script.git cd image-processing-script -
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` -
Install dependencies:
pip install -r requirements.txt
-
Create a new folder under the
images/original/directory for your image group (e.g.,images/original/my_group). -
Place your images in the newly created directory.
-
Open the
src/process_images.pyscript and update thegroup_namevariable:group_name = "my_group" # Replace with your folder name
-
Run the script:
python src/process_images.py -
Processed images will be saved in a corresponding folder under
images/processed/(e.g.,images/processed/my_group).
Modify the parameters in the process_directory function call at the end of the script to adjust:
- Input/output formats
- Image width
- Compression quality
For example:
process_directory(
input_dir,
output_dir,
input_format="jpg",
output_format="webp",
width=1024,
quality=75
)For more detailed customization, edit the process_directory function arguments in the script.