How to Convert Images to WebP
3 methods — PixelForge, cwebp CLI, and Python
WebP is the most widely supported next-gen image format — delivering 25–35% smaller files than JPEG and 25–50% smaller than PNG at equivalent visual quality. Every major browser supports it, Google's Core Web Vitals reward it, and most CDNs and modern CMSes handle it natively. Here are three ways to convert your existing images to WebP in bulk.
Method 1: Using PixelForge (fastest, no software needed)
Convert hundreds of images to WebP in one batch — no CLI, no Python, no Photoshop.
- 1Go to the Convert JPG to WebP or Convert PNG to WebP tool on PixelForge.
- 2Add your images to a ZIP file and upload it.
- 3Select WebP as the output format (it's pre-selected on the conversion tools).
- 4Optionally adjust quality — 80 is the recommended default for web use.
- 5Click Process and download your converted WebP images as a ZIP.
If your images are mixed formats (some JPG, some PNG), use the Bulk Image Convert tool and select WebP as the target. PixelForge converts all image formats to WebP in a single batch, preserving filenames.
Method 2: Using cwebp (Google's CLI tool)
Google's official cwebp encoder gives you precise control over encoding parameters. Best when you need fine-tuned quality control or want to automate conversion in a build pipeline.
- 1Install cwebp: On macOS, run 'brew install webp'. On Ubuntu/Debian, run 'sudo apt install webp'. On Windows, download the prebuilt binary from Google's developers site.
- 2Convert a single file: cwebp -q 80 input.jpg -o output.webp
- 3To batch-convert all JPEGs in a folder on macOS/Linux, run the script below.
- 4Check the output: cwebp prints the original and output file sizes so you can verify the savings.
bash
# Convert all JPEG and PNG files in ./images to WebP
# Output files go to ./webp with the same base name
mkdir -p webp
for f in images/*.{jpg,jpeg,png}; do
[ -f "$f" ] || continue
base=$(basename "${f%.*}")
cwebp -q 80 "$f" -o "webp/${base}.webp"
done
echo "Done!"Use -q 80 for photos (equivalent to JPEG ~85%). For graphics and illustrations, try -q 90 or use -lossless for pixel-perfect conversion. The -m 6 flag enables maximum compression (slower encoding, smallest output).
Method 3: Using Python (Pillow)
Scriptable WebP conversion — best for automated pipelines, server-side processing, or integrating into an existing Python workflow.
- 1Install Pillow: pip install Pillow
- 2Run the script below, pointing it at your input directory.
python
from PIL import Image
import os
input_dir = "./images"
output_dir = "./webp"
QUALITY = 80 # 80 is recommended for web photos; 90+ for graphics
os.makedirs(output_dir, exist_ok=True)
for filename in os.listdir(input_dir):
if filename.lower().endswith((".jpg", ".jpeg", ".png", ".gif", ".tiff")):
img = Image.open(os.path.join(input_dir, filename))
base = os.path.splitext(filename)[0]
out_path = os.path.join(output_dir, f"{base}.webp")
# Convert RGBA (PNG with transparency) or RGB
if img.mode in ("RGBA", "LA"):
img.save(out_path, "WEBP", quality=QUALITY, lossless=False)
else:
img = img.convert("RGB")
img.save(out_path, "WEBP", quality=QUALITY)
orig_size = os.path.getsize(os.path.join(input_dir, filename))
webp_size = os.path.getsize(out_path)
saving = (1 - webp_size / orig_size) * 100
print(f"{filename} → {base}.webp ({saving:.1f}% smaller)")
print("Done!")Pillow preserves transparency when converting PNG to WebP — no need to flatten transparent images. For maximum compression, add method=6 to the save() call (slower but produces the smallest WebP files).
Frequently asked questions
Is WebP supported in all browsers?
Yes — as of 2024, WebP is supported in all modern browsers including Chrome, Firefox, Safari (14+), and Edge. Global support exceeds 97%. For legacy support, serve WebP in a <picture> element with a JPEG fallback: <source type="image/webp" srcset="image.webp"> <img src="image.jpg">.
How much smaller are WebP files compared to JPEG and PNG?
WebP is typically 25–35% smaller than JPEG at equivalent perceptual quality, and 25–50% smaller than PNG for graphics and illustrations. Results vary by image content — photos with complex detail see smaller gains than flat graphics and illustrations.
Does WebP support transparency like PNG?
Yes — WebP supports full alpha channel transparency. This makes it a direct replacement for PNG in addition to JPEG. Transparent WebP images are typically 50% smaller than their PNG equivalents.
Should I serve WebP or AVIF?
WebP is the safer choice today — it has near-universal browser support and fast encoding. AVIF offers better compression (typically 20–30% smaller than WebP) but has slower encoding times and slightly lower browser support (~94%). For a production site, WebP now with a plan to migrate to AVIF when support matures is a reasonable approach.
Can I convert WebP back to JPEG or PNG?
Yes — use PixelForge's Convert WebP to JPG tool, or open the WebP in any modern browser and save as JPEG/PNG. WebP is a standard raster format and is fully reversible.
Ready to try the fastest method?
Convert JPEG images to WebP format in bulk. Smaller files, same quality — upgrade your web images for free.
JPG to WebP — free