← Back to Portfolio

ImageToWebPConverter

Converts .jpg, .jpeg, and .png images into optimized .webp format to reduce file size and improve website performance.

Python

🖼️ Image to WebP Converter

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.


🚀 Features

  • ✅ Converts images in bulk from a selected directory
  • ✅ Automatically saves output in a separate WebP_Compressed folder
  • ✅ Adjustable compression quality (0–100)
  • ✅ Displays original vs. compressed file sizes
  • ✅ Skips unsupported file types safely

📦 Requirements

Before running the script, ensure you have Python 3.8+ installed.
Install the required dependency using pip:

pip install Pillow

🧠 How It Works

The 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

🧩 Usage

  1. Clone or download this repository:

    git clone https://github.com/yourusername/webp-converter.git
    cd webp-converter
    
  2. Run the script:

    python convert_to_webp.py
    
  3. Enter the directory path containing your images when prompted.

  4. 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

🧮 Example Output

'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.

⚙️ Parameters

ParameterDescriptionDefault
directory_pathPath to the folder containing imagesRequired
qualityCompression quality (0–100)80

🧑‍💻 Author

Mete Şahan Kurt
📍 Istanbul, Turkey
💼 Student & Developer
📫 LinkedIn Profile


🪪 License

This project is licensed under the MIT License — you’re free to use, modify, and distribute it with attribution.


⭐ Contribute

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).