How Image Compression Works: Lossy vs Lossless Explained | Bulk Image Compressor

What Is Image Compression, Really?

Image compression is about reducing file size by removing data. That’s the whole concept. You take a file that’s, say, 5 MB, and you shrink it down to 500 KB or less. The question is always: what data gets removed, and will you notice the difference?

Every digital image is made up of pixels, and each pixel stores color information. A 4000x3000 photo has 12 million pixels, and if each one stores 24 bits of color data, that’s about 36 MB of raw information. Obviously, nobody wants to deal with 36 MB image files, so we compress them.

There are two approaches to this: lossy and lossless. They work differently, they produce different results, and they’re good for different things.

Lossy Compression: Throwing Away What You Won’t Miss

Lossy compression permanently removes some image data. You can’t get it back once it’s gone. That sounds bad, but here’s the thing: it’s designed to remove the stuff your eyes aren’t great at noticing anyway.

Human vision is better at perceiving changes in brightness than changes in color. We’re also not great at picking up fine details in busy, complex areas of an image. Lossy compression takes advantage of both of these facts.

How JPEG Compression Works

JPEG is the most common lossy format, and the way it works is pretty clever.

First, the image gets split into small 8x8 pixel blocks. Each block goes through something called a Discrete Cosine Transform (DCT). Don’t worry about the math. What DCT does is convert the pixel data from “here are the colors at each position” into “here are the patterns of change across this block.”

After that transformation, the data gets quantized. This is the step where information actually gets thrown away. The subtle, high-frequency details (tiny variations in color and brightness) get rounded down or eliminated. Your quality slider in any image editor controls how aggressively this quantization happens.

At quality 95, very little gets removed. At quality 30, a lot gets removed. The file size difference between those two settings can be enormous, often 10x or more.

The final step is entropy coding, which is just a lossless step that packs the remaining data as efficiently as possible. Think of it like zipping a file.

The Quality Tradeoff

Every lossy compression involves a tradeoff between file size and visual quality. The good news is that this tradeoff isn’t linear. Going from quality 100 to quality 80 might cut your file size by 70% with almost no visible difference. Going from 80 to 60 saves less space but starts to show artifacts, those blocky, smeared areas you sometimes see in heavily compressed photos.

For most photos, quality 75-85 is the sweet spot. You get massive file size savings and the image still looks great to most people. If you want to learn more about finding the right balance, check out our guide on how to reduce image file size without losing quality.

Lossless Compression: Keeping Every Pixel

Lossless compression reduces file size without removing any data at all. When you decompress the file, you get back the exact original, pixel for pixel. The tradeoff is that lossless files are bigger than lossy ones.

So how do you shrink a file without losing anything? By finding more efficient ways to describe the same data.

How PNG Compression Works

PNG is the most widely used lossless format. It uses a combination of filtering and DEFLATE compression (the same algorithm used in ZIP files).

Before compression, PNG applies filters to each row of pixels. Instead of storing the raw color value, it might store the difference between each pixel and the one next to it. In areas where colors change gradually, these differences are very small numbers, often zeros. Small, repetitive numbers compress much better than random-looking raw values.

After filtering, the data goes through DEFLATE, which finds repeated patterns and replaces them with shorter codes. If a sequence of pixels appears multiple times, it gets stored once and referenced everywhere else.

The result: you get a smaller file that’s still a perfect copy of the original. For a typical screenshot or graphic, PNG compression might cut file size by 50-70% without any quality loss.

Where Lossless Shines

Lossless compression works best when the image has large areas of identical colors, sharp edges, and text. Screenshots, logos, diagrams, UI elements, anything with flat colors and clean lines, these all compress really well with PNG.

Photos don’t compress as well with lossless methods because they have too much variation in every pixel. A photograph compressed losslessly might be 3-5x larger than the same photo saved as a JPEG at quality 80, and most people wouldn’t see the difference.

When to Use Each Type

Use lossy (JPEG) when:

  • You’re working with photographs
  • File size matters more than pixel-perfect accuracy
  • The image will be displayed on the web
  • You need to compress many images at once (try Bulk Image Compressor for batch processing)

Use lossless (PNG) when:

  • The image has text, logos, or sharp edges
  • You need transparency (PNG supports it, JPEG doesn’t)
  • You’re saving screenshots or UI mockups
  • You need to edit the image again later and want to preserve quality

What Quality Settings Actually Mean

When you adjust a quality slider from 1 to 100 in any image tool, you’re controlling how much data gets thrown away during the quantization step. But the numbers aren’t standardized across tools. Quality 80 in Photoshop, quality 80 in GIMP, and quality 80 in an online compressor can all produce different results.

What matters more than the number is the output. Compress your image, look at it, and check the file size. If it looks good and the file is small enough, you’re done. If it looks bad, bump the quality up a bit and try again.

A practical approach: start at quality 80 and compare against the original. Most of the time, you won’t see a difference. If you do, try 85 or 90. Below 70, compression artifacts become noticeable in most photos.

It Doesn’t Have to Be One or the Other

Modern formats like WebP actually support both lossy and lossless compression in the same format. You choose which mode to use when you save the file. This flexibility is one reason WebP has become so popular for web images. You can read more about format differences in our JPEG vs PNG vs WebP comparison.

The bottom line: compression is about making smart tradeoffs. Lossy works by removing data your eyes won’t miss. Lossless works by describing the same data more efficiently. Knowing which to use, and when, saves you time and keeps your images looking good at the smallest possible file size.

Ready to compress your images?

Bulk compress JPEG, PNG, WebP, and AVIF images right in your browser. No uploads, no sign-ups.

Try Bulk Image Compressor