
How to Compress Images Without Losing Quality: A Complete Guide
Learn the difference between lossy and lossless image compression, find the right quality settings for JPEG WebP and AVIF, and compress images without visible quality loss in 2026.
Every image on your website adds weight. A typical product page with 8 uncompressed JPEGs can easily hit 5 MB, which means slow loads, frustrated users, and lower search rankings. The fix is compression. But "compression" sounds like it should degrade your images, and plenty of people have ruined product photos by cranking a quality slider too far. This guide explains how compression actually works, where the quality sweet spots are, and how to shrink files without your users noticing any difference.
Lossy vs Lossless: The Fundamental Split
Lossy compression permanently discards data that the algorithm deems less perceptually important. Once you save a photo as JPEG at quality 80, the discarded detail is gone. You cannot recover it by re-saving at quality 100. Each subsequent lossy save degrades the image further, a phenomenon called generation loss.
Lossless compression preserves every pixel value. The file is smaller than the raw original, but when decoded, the output is bit-for-bit identical to the input. PNG uses a combination of filtering and DEFLATE compression to achieve this.
The choice is not always binary. Modern formats like WebP and AVIF support both lossy and lossless modes within the same container. WebP lossless is typically 26 percent smaller than PNG, while WebP lossy is 25 to 34 percent smaller than JPEG, according to Google's compression benchmarks.
How JPEG Compression Actually Works
Understanding the JPEG pipeline helps you make better decisions. JPEG compression follows these steps:
-
Color space conversion - The image is converted from RGB to YCbCr. Since human vision is less sensitive to color detail than brightness, the color channels can be downsampled (typically 4:2:0) without visible quality loss.
-
Block transform - The image is divided into 8x8 pixel blocks. Each block undergoes a discrete cosine transform (DCT), converting spatial data into frequency components.
-
Quantization - This is where quality loss happens. Higher frequencies (fine detail) are divided by larger numbers, effectively discarding them. The quality slider controls how aggressive this step is.
-
Entropy coding - The quantized coefficients are compressed using Huffman coding.
The quality parameter (0 to 100) primarily controls the quantization step size. Quality 80 to 85 gives excellent results for most photographs. Below 60, you start seeing visible 8x8 blocks and ringing around text and edges.
Quality Sweet Spots by Format
Each format has its own quality scale, and the numbers are not directly comparable. Here are the practical sweet spots based on testing with SSIMULACRA2 scores:
| Format | Sweet Spot | File Size (1920x1080 photo) | Visual Quality |
|---|---|---|---|
| JPEG (mozjpeg) | q80 to q85 | 210 to 260 KB | Excellent |
| WebP | q75 to q80 | 160 to 200 KB | Excellent |
| AVIF | q50 to q60 | 90 to 120 KB | Excellent |
The jump from q80 to q95 on a JPEG more than doubles the file size for about 9 points of SSIMULACRA2 improvement. Your users will not see that difference. For hero images on a marketing page, q80 to q82 is almost always the right answer. For thumbnails, q70 is fine.
When to Use Lossless Compression
Four cases where you should not compromise with lossy:
-
Source files and masters. If you will re-edit or re-export, keep a lossless original. Generation loss on JPEG is real. After five re-saves at q85, you lose about 4 SSIMULACRA2 points.
-
Screenshots and UI mockups. PNG or lossless WebP. JPEG's DCT will chew on 1-pixel borders and text edges, producing visible artifacts that look unprofessional.
-
Medical, legal, or scientific imagery. Self-explanatory. These require exact reproduction.
-
Icons and logos under 50 KB. The savings from lossy are measured in bytes. The risk of edge artifacts is not worth it.
For everything else, lossy in a modern codec beats lossless in an old one by a wide margin. A q60 AVIF of a photo often undercuts a zopflipng PNG of the same photo by 10x while remaining visually indistinguishable.
How to Compress Images Step by Step
-
Start with the right source. Always compress from the highest-quality original available. Compressing an already-compressed JPEG compounds quality loss.
-
Resize first. Scale the image to the dimensions it will actually be displayed at. Serving a 4000px photo in a 400px container wastes bandwidth and processing time.
-
Choose your format. Photos go to AVIF or WebP. Screenshots and graphics go to lossless WebP or PNG. Use JPEG only for email or compatibility contexts.
-
Set quality. Start at the sweet spot for your format (AVIF q55, WebP q78, JPEG q82). Inspect the output at 100 percent zoom. Raise quality only if fine detail has changed more than your use case allows.
-
Verify the result. Compare file size and visual quality. A 50 to 75 percent reduction is typical for camera-original JPEGs at quality 85 re-encoded at quality 82 with mozjpeg.
Real-World Examples
A wedding photographer delivering 400 client photos switched from JPEG q90 to WebP q80. Average file size dropped from 4.2 MB to 1.8 MB per image. Total delivery package went from 1.7 GB to 720 MB. Clients could not tell the difference in an A/B comparison. The photographer used the image compressor to process the entire batch in under 10 minutes.
A blog running on WordPress had 60 articles with uncompressed hero images averaging 1.8 MB each. After running them through AVIF compression at q55, average size dropped to 380 KB. Google PageSpeed Insights score went from 42 to 71 on mobile. The site used web.dev's image optimization recommendations as a reference.
An online store with 2,000 product photos converted from PNG to WebP lossy at q80. The product images were photographs on white backgrounds, so lossy compression was appropriate. Total catalog weight dropped from 8.4 GB to 2.1 GB. Page load time on product pages decreased by 1.4 seconds.
Benefits of Proper Compression
- 50 to 75 percent file size reduction for camera-original JPEGs with no visible quality loss
- Faster page loads directly improving Core Web Vitals and search rankings
- Lower bandwidth costs on hosting and CDN bills
- Better mobile experience on cellular data connections
- Reduced storage requirements for large image catalogs
Tips for Best Results
-
Use mozjpeg for JPEG encoding. Mozilla's mozjpeg recalculates Huffman tables per image and applies trellis quantization. Files are 10 to 40 percent smaller than standard libjpeg at equivalent quality.
-
Run PNG through oxipng or zopflipng. These lossless optimizers reduce PNG size by 15 to 30 percent with zero quality change. They remove unnecessary metadata and optimize the DEFLATE stream.
-
Compress last. Resize, crop, and apply all edits before compression. Each lossy re-save degrades quality.
-
Check your output. Do not trust the quality number alone. Look at the actual image at 100 percent zoom, especially around text, edges, and smooth gradients where artifacts show up first.
-
Use 4:2:0 chroma subsampling for photos. This halves the color data with no visible difference for photographic content. Switch to 4:4:4 only if you have red text on colored backgrounds.
FAQ
What quality setting should I use for JPEG?
Quality 80 to 85 with mozjpeg encoding is the sweet spot for photographs. The output is visually indistinguishable from the source in almost all viewing conditions. For thumbnails and small images, q70 is sufficient.
Is WebP quality 100 the same as lossless?
Yes. WebP quality 100 triggers lossless mode, not maximum-quality lossy mode. This is a common source of confusion. If you want the smallest lossy WebP, use q75 to q85, not q100.
How much can I compress an image without losing quality?
For camera-original JPEGs, you can typically achieve 50 to 75 percent file size reduction with no visible quality difference by re-encoding at the format's sweet spot with a good encoder. For already-optimized images, savings will be smaller.
Does compressing an image multiple times degrade quality?
Yes, if the compression is lossy. Each re-save applies another round of quantization, compounding artifacts. Always compress from the original source file, not from a previously compressed version.
Should I use AVIF or WebP for compression?
AVIF produces smaller files (15 to 25 percent smaller than WebP at equivalent quality) but encodes much slower. For build-time processing, AVIF is better. For on-demand processing, WebP is the practical choice. Use our WebP compressor or JPEG compressor depending on your format.
Can I compress PNG files without losing quality?
Yes. PNG is lossless by definition. You can optimize the PNG container with tools like oxipng to remove unnecessary metadata and improve the DEFLATE compression, typically saving 15 to 30 percent with zero pixel-level changes. For larger savings on suitable content, palette quantization (reducing to 256 colors) can save 40 to 70 percent.
Related Tools
- Image Compressor - Compress images in any format
- PNG Compressor - Optimize PNG files losslessly
- JPEG Compressor - Compress JPEG photos
- WebP Compressor - Compress WebP images
Conclusion
Compressing images without visible quality loss is not about finding a magic number. It is about understanding which format fits your content, where the perceptual sweet spots are, and always compressing from the original source. Start with AVIF q55 or WebP q78 for photographs, lossless WebP for screenshots, and verify the output at full zoom. The image compressor runs all of this in your browser, so your photos never leave your device. Give it a try on your next batch and watch your page weight drop.
Images Tool Box Team
Writing about image tools, optimization, and web performance.



