How to Convert Between Image Formats (PNG, JPG, WebP, AVIF)
Choosing the wrong format costs bandwidth, quality, or both. PNG at 400 KB where WebP at 80 KB does the same job. JPG where PNG was needed and the transparency is gone. Here's how to convert between formats and when each one is the right choice.
In the browser
Drop images into the Image Format Converter, select the target format and quality, then download. All processing runs client-side — files stay on your device. Supported conversions: PNG ↔ JPG, PNG ↔ WebP, JPG ↔ WebP, BMP → JPG/PNG, any → AVIF.
When to use each format
| Format | Best for | Transparency | Lossy | Typical size vs JPG |
|---|---|---|---|---|
| JPG | Photos, gradients | No | Yes | Baseline |
| PNG | Screenshots, logos, UI | Yes | No | Larger |
| WebP | Web images (all types) | Yes | Both | ~30% smaller |
| AVIF | Modern web, high compression | Yes | Both | ~50% smaller |
| BMP | Windows legacy, raw pixels | Yes | No | Much larger |
WebP is the safe default for new web projects — broad browser support since 2020, better compression than JPG, and full transparency support. AVIF is better still but requires Safari 16+ and Chrome 85+.
Python: Pillow
from PIL import Image
# PNG to JPG (must drop alpha channel first)
with Image.open('image.png') as img:
img.convert('RGB').save('image.jpg', quality=85)
# JPG to WebP
with Image.open('image.jpg') as img:
img.save('image.webp', quality=80)
# WebP to PNG
with Image.open('image.webp') as img:
img.save('image.png')
PNG has an alpha channel; JPG doesn't. .convert('RGB') flattens transparency to white before saving as JPG. Skip it and Pillow raises an error.
# Batch convert a folder of JPGs to WebP
from pathlib import Path
from PIL import Image
for f in Path('images/').glob('*.jpg'):
with Image.open(f) as img:
out = f.with_suffix('.webp')
img.save(out, quality=80)
print(f'{f.name} → {out.name}')
ImageMagick
# Single conversions
convert image.png image.jpg
convert image.jpg -quality 85 image.webp
convert image.png -quality 80 image.avif
# PNG to JPG — flatten transparency to white background
convert image.png -background white -flatten image.jpg
# Batch convert all PNGs to WebP in-place
mogrify -format webp -quality 80 *.png
# Check the format and dimensions of any file
identify image.webp
Quality settings
| Quality | File size | Visible difference |
|---|---|---|
| 95 | Large | None |
| 85 | Medium | None for most images |
| 75 | Small | Slight artifacts on sharp edges |
| 60 | Very small | Visible compression |
85 is the right default for JPG and WebP. Drop to 75 for thumbnails. Stay at 85+ for product or portfolio images.
Transparency and format compatibility
Three scenarios where format choice breaks things:
JPG strips transparency. Convert a PNG logo with a transparent background to JPG and the transparency becomes white (or black). Use WebP or PNG when you need a transparent background.
BMP is uncompressed. A 1920×1080 BMP is around 6 MB. Convert to PNG for lossless at ~1 MB, or JPG for photos at ~300 KB.
AVIF encoding is slow. AVIF produces the smallest files but encoding takes significantly longer than WebP or JPG. Fine for build pipelines; not ideal for real-time processing.
Key takeaways
- Use WebP for new web projects — ~30% smaller than JPG, transparency supported, broad browser support since 2020.
- Always
.convert('RGB')before saving PNG to JPG in Pillow — drops the alpha channel cleanly. mogrify(ImageMagick) batch-converts an entire folder in one command.- Quality 85 is the correct default for JPG and WebP; go lower only for thumbnails.
- AVIF gives the best compression but encoding is slow — use it in offline pipelines, not real-time.