What Is Image Compression?
Image Compression is a technique for reducing image file size within an acceptable range of visual quality loss. Its core idea is to eliminate information redundancies that are less perceptible to the human eye—such as subtle color variations and barely noticeable brightness differences—thereby significantly reducing file size while preserving overall visual experience.
Image compression is mainly divided into two categories: lossy compression and lossless compression. Lossy compression (such as JPG, WebP) trades file size for reduced image details, and is suitable for photos, product images, and other scenes where the human eye is less sensitive to subtle changes. Compression efficiency is high, achieving ratios of 5:1 to 20:1. Lossless compression (such as PNG, GIF) preserves exact image fidelity by optimizing encoding without any pixel loss. Compression ratios are lower (2:1 to 5:1), making it ideal for icons, screenshots, text images, and other scenes requiring precise pixel-perfect preservation.
From a technical perspective, lossy compression typically goes through three core steps: first, the image is transformed from the spatial domain to the frequency domain using Discrete Cosine Transform DCT, separating "low-frequency information sensitive to the human eye" from "high-frequency information less visible to humans"; then high-frequency coefficients are heavily compressed through a quantization matrix; finally, the quantized data is entropy-encoded using Huffman coding. Lossless compression typically employs predictive coding combined with LZ77, DEFLATE, and similar algorithms to eliminate data redundancy without changing any pixel values.
This tool implements image resampling and compression based on the browser's native Canvas API, entirely locally without any server upload. It supports custom quality parameters (0.1-1.0), maximum width limits, and multiple output formats including JPG, PNG, and WebP, giving you precise control over compression results.