← Blog

How Image Compression Works

Your photos are bigger than they need to be. Here is how image compression works and how to shrink files without ruining them.

A single photo from a modern phone runs four or five megabytes. Multiply that by a folder of vacation pictures or a web page full of product shots and the weight adds up fast. On the median web page in 2021, images were 881 of the 2,019 kilobytes, which is more than the HTML, the CSS, and the fonts put together. Most of that weight is optional.

Compressing an image is the act of making the file smaller. How much smaller depends on a choice you make every time you do it. That choice is quality, and it is worth understanding what it actually trades away.

Two Kinds of Smaller

There are two ways to shrink an image and they are not the same.

Lossless compression finds repetition in the data and stores it more efficiently. Nothing is discarded. When the file is opened again every pixel is exactly what it was. PNG works this way, and so does TIFF in its common forms. This is the right choice for screenshots, logos, and line art where sharp edges have to stay sharp.

Lossy compression goes further. It permanently throws away information your eye is unlikely to miss. The file gets much smaller and the discarded detail never comes back. JPEG and HEIC work this way. This is the right choice for photographs, where a little lost detail is invisible.

The quality slider only means something for the lossy formats. There is no quality knob on a lossless file because nothing is being thrown away in the first place.

What Quality Means Inside a JPEG

A JPEG does not store your photo as a grid of pixels. It breaks the image into small blocks and describes each block as a set of frequencies using a discrete cosine transform. Smooth areas need only a few low frequencies. Fine detail needs the high frequencies too.

Then comes the step that does the compressing. The encoder rounds off those frequency values in a process called quantization. The quality setting controls how coarse that rounding is. A high quality keeps most of the frequencies and the file stays large. A low quality drops the high frequencies first, which is exactly why an over-compressed JPEG looks blocky and smears around sharp edges.

On a Mac this setting is a single number from zero to one. Apple’s imaging framework calls it the lossy compression quality. A quality slider in an image app is just a friendlier face on that one number.

Why HEIC Gets More From Less

HEIC is the format your iPhone uses out of the box. It wraps the same compression engine that HEVC video uses, and that engine is far more modern than the one inside JPEG. It predicts blocks from their neighbors, uses larger and more flexible transforms, and packs the result more tightly.

The payoff is real. A HEIC photo takes about half the space of a JPEG at the same quality. Apple made it the default on iPhones in 2017 with iOS 11. Converting a pile of JPEGs to HEIC is one of the largest single savings available, as long as wherever you are sending those images can read the format.

The Part Everyone Forgets

Photographs carry more than pixels. Every image your camera saves also holds EXIF metadata. That is the camera model, the lens, the exposure settings, the date and time, and very often the exact GPS coordinates where the photo was taken.

That metadata is a small part of the file size. It is a large part of your privacy. A photo posted with its location intact tells everyone who sees it where you were standing. Stripping EXIF before you share is a good habit, and a good compressor makes it a single switch.

Where This Leaves You

Good compression is a series of small, informed choices. Pick lossy for photographs and lossless for graphics. Keep the quality high enough that the artifacts stay invisible and low enough that the file is worth sending. Convert to HEIC when the destination can read it. Strip the metadata you do not want to hand out.

This is the approach Honedown takes. It lives in the menu bar and gives you the quality slider for JPEG and HEIC, format conversion across PNG, JPEG, HEIC, and TIFF, and one toggle for EXIF. Every image is processed on your Mac with Apple’s own imaging framework, so nothing is uploaded and nothing leaves the machine. The savings show up right next to each file, in green.

Sources

  1. HTTP Archive. “The 2022 Web Almanac: Media.” almanac.httparchive.org

  2. MDN Web Docs. “Image file type and format guide.” developer.mozilla.org

  3. Wikipedia. “JPEG.” en.wikipedia.org

  4. Wikipedia. “High Efficiency Image File Format.” en.wikipedia.org

  5. Apple Developer Documentation. “kCGImageDestinationLossyCompressionQuality.” developer.apple.com