🍋
Menu
Image

WebP

WebP Image Format

A modern image format by Google offering both lossy and lossless compression with smaller file sizes than JPEG/PNG.

Technical Detail

WebP works by exploiting limitations in human visual perception. The Discrete Cosine Transform (DCT) used in JPEG breaks images into 8x8 pixel blocks and converts spatial data to frequency coefficients. High-frequency details (fine textures, sharp edges) are quantized more aggressively than low-frequency information (smooth gradients). Each additional compression pass (re-saving) compounds quality loss — a phenomenon called generation loss — making lossy formats unsuitable for iterative editing workflows.

Example

```javascript
// Image compression via Canvas
canvas.toBlob(
  blob => console.log(`Size: ${(blob.size/1024).toFixed(0)} KB`),
  'image/jpeg',
  0.8  // quality: 0.0 (smallest) to 1.0 (best)
);

// WebP output (25-34% smaller than JPEG)
canvas.toBlob(cb, 'image/webp', 0.8);
```

Related Formats

Related Tools

Related Terms