Home Image Editing Basics of image compression (differences...
Image Editing

Basics of image compression (differences between JPEG, PNG, and WebP and how to use them)

Mar 16, 2026 Updated Apr 20, 2026 Benri-Kit
Tips

Image Compression Basics: Differences Between JPEG, PNG, and WebP, and When to Use Each

JPEG PNG WebP
00

Introduction

When building websites or apps, have you ever wondered which image format to use?

JPEG, PNG, WebP… With so many options, it can be confusing, right? But once you understand the characteristics of each, you’ll naturally know which one to use in which situation.

In this article, we’ll explain the mechanics and proper usage of these three image formats in an easy-to-understand way.

01

What Is Image Compression?

Why is compression necessary?

Digital photos generate a huge amount of data when left uncompressed. If you use large images on a website…

  • Page load times will slow down
  • Users are more likely to leave
  • Server bandwidth costs increase

That’s why we use “image compression” to reduce file sizes while preserving image quality as much as possible.

Two Types of Compression: Lossless and Lossy

Lossless compression

Compression that allows the original data to be fully restored. While image quality does not degrade, file sizes tend to be larger. It works the same way as unzipping a ZIP file.

Lossy Compression

Compression that removes some data. File sizes are significantly reduced, but the data cannot be restored to its original state. It removes parts that are difficult for the human eye to notice.

How to Remember
"Lossless" = can be reversed; "Lossy" = cannot be reversed. Think of lossless as being like a ZIP file that can be restored to its original state when decompressed, while lossy means that once compressed, it cannot be restored to its original state.
02

JPEG — The King of Photos

JPEG

Joint Photographic Experts Group

Developed in 1992 / Lossy compression / Specialized for photos

Lossy

A format developed specifically for storing photos. It can significantly reduce file sizes through lossy compression. A key feature is the ability to freely adjust the compression rate using the "Quality" parameter (0–100).

How JPEG Works (In Brief)
This format takes advantage of the fact that "the human eye is sensitive to changes in brightness but insensitive to subtle changes in color." It divides the image into 8×8-pixel blocks and compresses it by removing subtle color information that the human eye is unlikely to notice.
Advantages
  • Very small file size
  • Ideal for compressing photos
  • Compatible with all browsers and devices
  • Quality can be freely adjusted
Disadvantages
  • Cannot render transparency
  • Image quality degrades with repeated saves
  • Not suitable for text, lines, or illustrations
  • Does not support animation

Suitable Images

Landscape photos, portraits, web hero images, thumbnails, social media photos, blog images
The Pitfalls of JPEG Degradation
JPEG image quality degrades every time you save it. Repeatedly making minor edits and saving over the original will cause the quality to decline progressively. The best practice is to save your work as a PSD or PNG while editing, and then export it to JPEG only when you’re finished.
03

PNG — The Standard for Quality and Transparency

PNG

Portable Network Graphics

Developed in 1996 / Lossless compression / Supports transparency

Lossless

Because it uses lossless compression, image quality does not degrade no matter how many times you save it. Another major difference from JPEG is its ability to support transparency (alpha channel). It is ideal for logos and illustrations.

How PNG Works (In Brief)
It uses the "DEFLATE" algorithm, similar to ZIP. It compresses patterns by identifying sequences such as "this color continues for 100 pixels." Since all data is preserved, the image can be fully restored to its original state; however, the compression rate is lower for complex color variations found in photographs.
Advantages
  • No loss of image quality
  • Supports transparency
  • Ideal for text, logos, and illustrations
  • Quality is maintained no matter how many times it is saved
Disadvantages
  • Photos result in larger file sizes
  • Does not support animations (except APNG)
  • Can affect web page loading speed

Suitable images

Logos, icons, illustrations with transparent backgrounds, screenshots, images with text, line art, shapes, graphs, and favicons
PNG-8 vs PNG-24
PNG comes in two formats: "PNG-8" (up to 256 colors) with a limited color palette, and "PNG-24" (16.77 million colors) for full color. For simple illustrations or icons, PNG-8 can help keep file sizes small. PNG-24 is required for gradients and photographs.
04

WebP — The Optimal Solution for the Modern Web

WebP

Web Picture Format (developed by Google)

Developed in 2010 / Supports both lossless and lossy compression / Supports transparency and animation

Lossy + Lossless

A relatively new format developed by Google. It aims to "combine the best of JPEG and PNG," achieving image quality equal to or better than JPEG with file sizes approximately 25–35% smaller. It supports both transparency and animation.

How WebP Works (In Brief)
Based on the VP8 video codec technology. It uses an advanced method that predicts the colors of adjacent pixels and records only the differences. Since it processes in smaller blocks (4×4) than JPEG, it produces less edge noise and maintains sharper image quality.
Benefits
  • Files are approximately 25–35% smaller than JPEG
  • Files are approximately 25% smaller than JPEG
  • Supports transparency and animation
  • Works with both photos and illustrations
  • Compatible with all major browsers
Disadvantages
  • Not compatible with IE (older browsers)
  • Difficult to edit in some design tools
  • May not open in some apps, such as Windows Photo Viewer

Suitable images

General websites, product images on e-commerce sites, mobile sites, performance-critical pages, and as an alternative to GIF animations
WebP is the standard of the future
Support in major browsers was completed in 2023 and beyond. It is recommended to prioritize WebP for new web projects. Frameworks such as Next.js and Nuxt also offer features that automatically convert images to WebP.
05

Summary of the 3 formats

ItemJPEGPNGWebP
Compression MethodLossyLosslessBoth supported
File sizeSmallLargeSmallest
Image quality degradationYes (adjustable)NoneVirtually none
TransparencyNot supportedSupportedSupported
AnimationNot supportedNot supportedSupported
Portrait orientation◎ Best△ Not suitable◎ Best
Suitable for illustrations and logos△ Not suitable◎ Ideal○ Good
Browser Compatibility◎ Fully supported◎ Fully supported○ Supports major browsers
06

Practical Guide: How to Choose

Recommendations by Scenario

ScenarioRecommendationsReason
Website PhotosWebP (Runner-up: JPEG)Small file size and fast loading
Company Logo / Site LogoPNG / SVGSupports transparency and no loss of quality
ScreenshotsPNGText appears crisp
Product Images (E-commerce)WebP (Runner-up: JPEG)Good balance between image quality and loading speed
Banners (with text)PNG / WebPText does not blur
Email attachmentsJPEGHigh compatibility
App iconsPNG / WebPSupports transparency and small file sizes
Alternative to animated GIFsWebPSignificantly smaller file size

Decision Flowchart

1
Do you need transparency?
YESPNG or WebP
NO → Next
2
Do you need animation?
YESWebP
NO → Next
3
Is it a photo? Or an illustration, logo, or text?
PhotoWebP (Second choice: JPEG)
Illustration/Logo/TextPNG or WebP
4
Do you need to support older browsers (IE)?
YESJPEG or PNG
NOWebP is best!
07

How to handle it in code

Embedding images in HTML

To prioritize WebP while providing JPEG to unsupported browsers, <picture> Use the tag.

HTML
<!-- pictureタグを使ったフォールバック -->
<picture>
  <!-- WebP対応ブラウザはこちらを使う -->
  <source srcset="image.webp" type="image/webp">
  <!-- 非対応ブラウザはJPEGに切り替わる -->
  <source srcset="image.jpg" type="image/jpeg">
  <!-- 最後はimg要素(必須) -->
  <img src="image.jpg" alt="説明文">
</picture>

Writing it this way ensures that WebP-compatible browsers display the fast WebP version, while non-compatible browsers automatically display the highly compatible JPEG version.

Converting to WebP in Python

You can convert images in just a few lines using Python's Pillow (PIL) library. To install it, pip install Pillow here.

Python
from PIL import Image

# JPEG を WebP に変換(非可逆、quality=85 が一般的)
img = Image.open("photo.jpg")
img.save("photo.webp", "WEBP", quality=85)

# PNG を WebP(透過あり)に変換(可逆)
img = Image.open("logo.png")
img.save("logo.webp", "WEBP", lossless=True)

# フォルダ内の全JPEGをまとめて変換
import os

for filename in os.listdir("./images"):
    if filename.endswith(".jpg"):
        img = Image.open(f"./images/{filename}")
        name = filename.replace(".jpg", ".webp")
        img.save(f"./output/{name}", "WEBP", quality=85)
        print(f"変換完了: {name}")
08

Summary

JPEG
The King of Photos

A versatile format with small file sizes that works worldwide. However, it does not support transparency, and image quality degrades with each save.

PNG
The Standard for Transparency and Quality

Supports transparency and lossless saving. Ideal for logos, illustrations, and screenshots. Photo files tend to be larger.

WebP
The optimal solution for modern web

Combines the best of both JPEG and PNG while minimizing file size. Make this your first choice for new projects.

Advice for Beginners
To start, just remember: "Photos → JPEG, Logos & Transparent Images → PNG." Once you get the hang of it, try switching to WebP. If you’re using frameworks like Next.js or Nuxt, they often have automatic conversion features, so you usually don’t need to worry too much.

I hope this article helps you understand image formats.