A lightweight Python tool that converts .jpg, .jpeg, and .png images into optimized .webp format for faster website loading and reduced file size — without noticeable quality loss.
- ✅ Converts images in bulk from a selected directory
- ✅ Automatically saves output in a separate
WebP_Compressedfolder - ✅ Adjustable compression quality (0–100)
- ✅ Displays original vs. compressed file sizes
- ✅ Skips unsupported file types safely
Before running the script, ensure you have Python 3.8+ installed.
Install the required dependency using pip:
pip install PillowThe script scans the target folder for all .jpg, .jpeg, and .png files, then converts them into .webp format using the Pillow library.
All converted images are stored in a new folder inside the same directory:
/YourDirectory
│
├── image1.jpg
├── image2.png
└── WebP_Compressed/
├── image1.webp
└── image2.webp
-
Clone or download this repository:
git clone https://github.com/yourusername/webp-converter.git cd webp-converter -
Run the script:
python convert_to_webp.py
-
Enter the directory path containing your images when prompted.
-
Choose a compression quality between 0 (lowest) and 100 (highest).
The default quality is 80 if you skip or enter an invalid value.
Example:
Lütfen dönüştürmek istediğiniz klasörün yolunu girin: C:\Users\Mete\Pictures
Lütfen sıkıştırma kalitesi girin (0-100 arası, örn: 75): 80
'image1.jpg' (254.32 KB) başarıyla WebP'ye dönüştürüldü ve 'WebP_Compressed/image1.webp' konumuna (68.90 KB) kaydedildi.
'image2.png' (512.08 KB) başarıyla WebP'ye dönüştürüldü ve 'WebP_Compressed/image2.webp' konumuna (130.77 KB) kaydedildi.
| Parameter | Description | Default |
|---|---|---|
directory_path |
Path to the folder containing images | Required |
quality |
Compression quality (0–100) | 80 |
Mete Şahan Kurt
📍 Istanbul, Turkey
💼 Student & Developer
📫 LinkedIn Profile
This project is licensed under the MIT License — you’re free to use, modify, and distribute it with attribution.
If you find this project useful, consider giving it a ⭐ on GitHub or contributing with new features (e.g., recursive folder support, GUI version, or drag-and-drop functionality).