How to Compress Images Without Losing Quality
Image Guides

How to Compress Images Without Losing Quality

Michael Foster

Michael Foster

Content Creator & Tutorial Expert

Feb 6, 2026 Mar 12, 2026 8 min
Reviewed by Emma RodriguezFact-checkedEditorial Policy

Image compression is essential for web performance, but doing it wrong can ruin your visuals. This guide explains the difference between lossy and lossless compression, the best tools and settings, and how to shrink file sizes without visible quality loss.

Image compression is the art of making image files smaller without making them look worse. It is one of the most important skills for anyone who publishes images on the web, because file size directly affects page load speed, user experience, and search rankings. But compression is also one of the most misunderstood topics in image editing, partly because the word compression is used to mean two very different things. This guide explains the difference between lossy and lossless compression, walks through the best tools and settings for each format, and shows you how to shrink your image files dramatically with no visible quality loss.

Two Types of Compression: Lossy and Lossless

All image compression falls into one of two categories, and understanding the difference is the foundation of everything else.

Lossless Compression

Lossless compression reduces file size by finding more efficient ways to encode the same information. No pixel data is discarded. When you decompress a losslessly compressed image, you get back exactly what you put in, pixel for pixel.

Lossless compression works by identifying patterns. If a row of 100 pixels is all the same shade of blue, a lossless algorithm can encode that as "100 pixels of blue" instead of storing 100 identical color values. The savings depend on the content — images with large areas of solid color compress very well, while noisy, detailed images compress poorly.

Formats that support lossless compression include PNG, lossless WebP, and TIFF. The trade-off is that lossless compression has a floor: once you have encoded the patterns efficiently, you cannot make the file any smaller without discarding information.

Lossy Compression

Lossy compression reduces file size by discarding information that the human eye is less likely to notice. The algorithm analyzes the image, identifies details that are less perceptually important — subtle color variations, high-frequency noise, fine texture — and throws them away. The result is a file that looks very similar to the original but is much smaller.

The amount of information discarded is controlled by a quality setting, usually from 1 to 100. Higher quality settings keep more information and produce larger files; lower settings discard more and produce smaller files. At some point, the discarded information becomes visible — the image starts to show blocky artifacts, smeared details, and color shifts.

Formats that use lossy compression include JPG, lossy WebP, and AVIF. The advantage of lossy compression is that it can achieve much smaller file sizes than lossless compression, often 5 to 20 times smaller for the same image. The disadvantage is that the loss is permanent — once the information is discarded, you cannot get it back.

Which Type Should You Use?

The choice depends on the content and the use case.

  • For photographs on the web: Use lossy compression (JPG, lossy WebP, or AVIF). The file size savings are huge, and at the right quality setting, the quality loss is invisible.
  • For graphics with text, sharp edges, or transparency: Use lossless compression (PNG or lossless WebP). Lossy compression would introduce visible artifacts on text and edges.
  • For images you will edit again: Keep a lossless master and only export to a lossy format as the final step. Never use lossy compression on a working file.

Best Compression Settings for Each Format

JPG Compression

JPG uses a quality scale from 1 to 100. The right setting depends on the content and your tolerance for artifacts.

  • Quality 90 to 95: Very high quality, nearly indistinguishable from the original. Files are still relatively large. Use for portfolio images where quality matters most.
  • Quality 80 to 85: The sweet spot for most web use. Files are much smaller than quality 90, and the quality loss is invisible to most viewers. This is the recommended default for web photographs.
  • Quality 70 to 75: Noticeably smaller files, with very subtle artifacts visible only on close inspection. Good for thumbnails and images where file size matters more than perfection.
  • Quality 50 to 60: Small files with visible artifacts. Use only when file size is the overriding concern and quality is secondary.
  • Below 50: Severe artifacts. Generally not acceptable for most uses.

PNG Compression

PNG uses a compression level from 0 to 9, but this setting is widely misunderstood. Higher levels produce slightly smaller files but take longer to encode — the visual quality is identical at every level because PNG is lossless. For most uses, level 6 (the default in most tools) is a good balance of size and speed. Level 9 produces slightly smaller files but takes much longer to save.

The real way to reduce PNG file size is to reduce the color depth. An 8-bit palette PNG (up to 256 colors) is much smaller than a 24-bit truecolor PNG and is the right choice for simple graphics, icons, and illustrations with limited color palettes.

WebP Compression

WebP supports both lossy and lossless compression, making it the most flexible format.

  • Lossy WebP at quality 80: Roughly 25 to 35 percent smaller than JPG at the same visual quality.
  • Lossless WebP: Roughly 20 to 30 percent smaller than PNG for the same content.

For most web images in 2026, lossy WebP at quality 80 is the best default for photographs, and lossless WebP is the best choice for graphics with transparency or text.

AVIF Compression

AVIF offers the best compression of any widely supported format. At similar visual quality to a JPG at quality 80, an AVIF file is typically 30 to 50 percent smaller. The trade-off is that AVIF encoding is slower, which matters for bulk processing but not for one-off exports.

Tools for Compressing Images

Online Image Compressors

Online compressors are the fastest option for occasional use. Upload an image, choose your settings, and download the compressed result. Many online tools also let you compare the original and compressed versions side by side so you can judge the quality before committing.

Best for: One-off compression, users who do not want to install software, quick experiments with different quality settings.

Desktop Software

For frequent or batch compression, desktop software is more efficient. Tools like ImageOptim (macOS), FileOptimizer (Windows), and Trimage (Linux) compress images by stripping unnecessary metadata and applying optimal encoding. Professional editors like Photoshop and Affinity Photo have export dialogs with fine-grained control over compression settings.

Best for: Frequent compression, batch processing, users who want maximum control over settings.

Command-Line Tools

For developers and automation, command-line tools are the most powerful option. Tools like cwebp (WebP), avifenc (AVIF), jpegtran (JPG), and optipng (PNG) can be scripted to compress entire folders of images with consistent settings.

Best for: Automated workflows, build pipelines, developers who want reproducible compression.

CMS Plugins and CDN Compression

Many content management systems and CDNs offer automatic image compression on upload. WordPress plugins like Smush and ShortPixel, and CDN services like Cloudflare and Cloudinary, compress images automatically as they pass through the system.

Best for: Set-and-forget compression on websites where you do not want to think about compression manually.

Step-by-Step: Compressing an Image for the Web

Here is a complete workflow for compressing a photograph for web use.

  1. Start with the highest-quality source you have. Compression works best when applied to a clean, high-resolution original. Never compress an already-compressed image — each lossy compression step degrades quality.
  2. Resize the image to the dimensions it will be displayed at. If the image will be shown at 800 pixels wide, resize it to 800 pixels wide. Do not upload a 4000-pixel image and let the browser scale it down — that wastes bandwidth.
  3. Choose your format. For a photograph, use WebP (or AVIF for the best compression). For a graphic with transparency, use lossless WebP or PNG.
  4. Set the quality. Start at 80 for lossy formats. Export the image and look at the result.
  5. Compare to the original. Look closely at detailed areas, smooth gradients, and edges. If you see artifacts, increase the quality. If the image looks fine, try a lower quality setting to see if you can save more size.
  6. Check the file size. The goal is the smallest file that looks acceptable. A 200 KB image that looks great is better than a 500 KB image that looks identical.
  7. Save and use. Once you find the right settings, save the compressed image and use it on your site.

Advanced Techniques

Responsive Images

Serve different image sizes to different devices. A phone does not need the same 2000-pixel-wide image as a desktop monitor. Use the srcset attribute or the picture element to provide multiple sizes, and let the browser choose the right one.

Lazy Loading

Only load images when they enter the viewport. This delays the download of images the user might never see, speeding up the initial page load. Most modern browsers support lazy loading natively with the loading="lazy" attribute.

Stripping Metadata

Image files often contain metadata — EXIF data from cameras, color profiles, thumbnails, comments. This metadata adds to the file size without affecting the visible image. Most compression tools can strip this metadata, saving a few kilobytes per image. The savings are small per image but add up across a large site.

Comparing Compression Tools

Different tools produce different results even at the same quality setting, because they use different encoders and algorithms. If you are serious about optimization, try compressing the same image with several tools and compare the file sizes and visual quality. You may find that one tool consistently produces smaller files at the same visual quality.

Common Compression Mistakes

Compressing an Already-Compressed Image

Every lossy compression step loses information. If you take a JPG from the web, edit it, and save it as a JPG again, you lose quality twice. Always work from a lossless master and compress only as the final step.

Using Too-High Quality Settings

Quality 95 produces files nearly as large as the original with no visible improvement over quality 80 for most web images. The extra file size slows your page with no benefit to the viewer.

Forgetting to Resize First

Compression reduces file size, but the biggest savings come from resizing the image to the right dimensions. A 4000-pixel image at quality 80 is still much larger than an 800-pixel image at quality 80. Always resize first, then compress.

Using the Wrong Format

Compressing a graphic with text as a JPG produces artifacts around the text. Compressing a photograph as a PNG produces a file 10 times larger than necessary. Match the format to the content.

Conclusion

Compressing images without losing quality is a matter of understanding the difference between lossy and lossless compression, choosing the right format for your content, and finding the quality setting that gives the smallest file with no visible artifacts. For most web photographs in 2026, that means lossy WebP at quality 80, or AVIF for even better compression. For graphics with text or transparency, it means lossless WebP or PNG. Always start from a high-quality source, resize to the display dimensions first, and compress as the final step. Do this consistently and your images will look great while your pages load fast.

Share

About the Author

Michael Foster

Michael Foster

Content Creator & Tutorial Expert

Michael creates in-depth tutorials and guides that make complex tools accessible to everyone. He has a passion for teaching and clear communication.

5+ years creating educational content for tech products
Skills & Expertise
Technical WritingTutorial DesignUser EducationContent Strategy

Frequently Asked Questions

What is the best quality setting for JPG compression?
For most web photographs, quality 80 to 85 is the sweet spot — files are much smaller than at quality 90, and the quality loss is invisible to most viewers. Quality 90 to 95 is better for portfolio images where quality matters most. Below 70, artifacts become visible.
Does lossless compression reduce file size?
Yes, but only up to a point. Lossless compression finds more efficient ways to encode the same pixel data, which can reduce file size significantly for images with large areas of solid color. For noisy, detailed images like photographs, lossless compression has limited effect, which is why lossy formats are used for photos.
Can I compress an image multiple times without quality loss?
Only with lossless formats like PNG. With lossy formats like JPG, every save discards more information, causing generation loss. Always keep a lossless master and compress to a lossy format only as the final step.
Which format gives the smallest file size?
AVIF generally produces the smallest files at a given visual quality, followed by WebP, then JPG. For graphics with transparency, lossless WebP is smaller than PNG. The exact savings depend on the content of the image.
Should I strip metadata when compressing images?
For web use, yes. Metadata like EXIF data, thumbnails, and comments adds to file size without affecting the visible image. Stripping it saves a few kilobytes per image, which adds up across a large site. Keep metadata only if you specifically need it, such as copyright information or color profiles.

Start working smarter today

Join 500,000+ users who trust VisualDocs for their daily image and PDF workflows.