How Image Compression Works
Image compression removes redundant information while preserving visual detail that people care about. Different algorithms use different tradeoffs between quality, size, and encoding speed.
Lossless vs lossy compression
Lossless compression keeps every original pixel value. It reduces file size by storing repeated patterns more efficiently.
Lossy compression removes less visible information to achieve much smaller files. This usually brings larger savings for photos.
How JPEG style compression works
JPEG converts image blocks into frequency data, then quantizes higher-frequency detail more aggressively.
When you lower quality, quantization becomes stronger, so edges and textures may look softer while file size drops quickly.
Modern codecs and practical tradeoffs
WebP and AVIF combine newer prediction and entropy coding techniques, so they often keep similar quality at smaller sizes than JPEG.
In production, the best result usually comes from testing a few quality levels against your real images instead of picking one fixed preset.