A Python script that converts images to WebP format and creates multiple resized versions for responsive web design. Perfect for generating source sets for modern websites.
- 🔄 Convert multiple image formats to WebP
- 📱 Generate multiple responsive image sizes
- 🎯 Maintain aspect ratio during resizing
- 📁 Organized folder structure output
- ⚡ Fast batch processing
- 🛠️ Configurable quality settings
- 📄 Detailed processing summary
- JPEG/JPG
- PNG
- WebP
- BMP
- TIFF/TIF
- GIF
- Python 3.6 or higher
- pip (Python package manager)
- Clone or download this repository
- Install required dependencies:
pip install -r requirements.txtpython sourcesetmaker.py --folder "/path/to/your/images" --savepath "/path/to/output"
--folder "/path/to/your/images" \
--savepath "/path/to/output" \
--widths 320 640 960 1200 1600 \
--quality 85<picture>
<source
type="image/webp"
srcset="
images/320/photo.webp 320w,
images/640/photo.webp 640w,
images/960/photo.webp 960w,
images/originalsize/photo.webp 1200w"
sizes="(max-width: 400px) 320px,
(max-width: 800px) 640px,
960px">
<img
src="images/originalsize/photo.webp"
alt="Description"
loading="lazy">
</picture>