Bulk image resizer and watermarker
Resize, compress and watermark hundreds of photos at once, ready for a website or Instagram.
Beginnerâą 3â5 hoursđĒ 7 stepsPythonPillow
What you'll learn
- âImage processing with Pillow
- âBatch processing folders
- âKeeping aspect ratio and EXIF rotation
What you'll build
- âResize to a max width keeping aspect ratio
- âConvert to WebP or JPEG with a quality setting
- âAdd a text or logo watermark
- âShows saved space at the end
Step-by-step guide
- 1
Install Pillow
pip install Pillow; open an image with Image.open(path).
- 2
Fix rotation
Call ImageOps.exif_transpose(img) so phone photos are not sideways.
- 3
Resize
Use img.thumbnail((max_w, max_w * 10)) which keeps the aspect ratio and never upscales.
- 4
Watermark
Create an RGBA layer, draw text with ImageDraw.text and a semi-transparent fill, or paste a logo PNG with its alpha mask, then alpha_composite.
- 5
Save compressed
img.convert("RGB").save(out, "JPEG", quality=80, optimize=True) or format "WEBP".
- 6
Process a folder
Loop over Path(src).glob("*.[jp][pn]g"), write to an output folder and keep a running total of bytes before and after.
- 7
Add options
argparse flags: --width, --quality, --format, --watermark "text".
đ Make it stand out
- +Use concurrent.futures to process in parallel
- +Add a drag-and-drop Tkinter window
- +Generate square thumbnails for a gallery