This Python script batch processes images by resizing them to a target resolution and applying a blurred background effect. It supports various image formats and allows for optional format conversion. The output images are saved in a specified destination folder.
- Resizes images to a given resolution while maintaining the aspect ratio.
- Applies a blurred background effect to fill the empty space around the resized image.
- Supports multiple common image formats.
- Optionally converts images to a specified format.
- Logs progress and errors using Python's
logging
module.
.bmp
,.dib
(Windows bitmaps).jpeg
,.jpg
,.jpe
(JPEG).jp2
(JPEG 2000).png
(Portable Network Graphics).webp
(WebP).tiff
,.tif
(TIFF).hdr
,.pic
(Radiance HDR)
- Python 3.7+
- OpenCV (
cv2
) - Numpy
You can install the required dependencies using pip
:
pip install -r requirements.txt
The script takes the source folder, destination folder, and several optional parameters such as the output format and resolution.
python script.py <src_folder> <dst_folder>
<src_folder>
: The source folder containing the images to process.<dst_folder>
: The destination folder to save the processed images.
--format
: Convert images to a specific format (e.g.,.jpg
,.png
).--resolution
: Output resolution in the formatwidth height
(default is1920 1080
).
Resize all images in the input_images
folder to 1280x720
and save them as .jpg
files in the output_images
folder:
python script.py input_images output_images --format .jpg --resolution 1280 720
Feel free to open an issue or submit a pull request if you encounter any problems or have suggestions for improvements.
This project is licensed under the MIT License. See the LICENSE
file for more details.