How Image Compression Works: The Basics

2025-10-24

For some reason, you can actually fit 2 million pixels into an image without using 1.97 megabytes of space. I found a sweet 1080p wallpaper (which has roughly 2 million pixels) and downloaded it. Checking the properties, I noticed something strange: It only took up 230 KB of space on my hard drive. Why is that? For someone who doesn’t quite understand image compression, it seems like magic. But once you get to know the subject, you’ll understand how some images are larger than others despite the amount of pixels they occupy on your screen. Time is short, so let’s take a quick dive into the basic principles behind image compression.

Methods, Approaches, Algorithms Galore.

imagecompression-method

It’s naive to think that there’s just one way to compress an image. There are different methods, each with a unique approach to a common problem, and each approach being used in different algorithms to reach a similar conclusion. Each algorithm is represented by a file format (PNG, JPG, GIF, etc.). For now, we’re going to talk about the methods that are generally used to compress images, which will explain why some of them take up so much less space.

Lossless Compression

imagecompression-lossless

When you think of the word “lossless” in the context of image compression, you probably think about a method that tries its hardest to preserve quality while still maintaining a relatively small image size. That’s very close to the truth. As a method, lossless compression minimizes distortion as much as possible, preserving image clarity. It does this by building an index of all the pixels and grouping same-colored pixels together. It’s kind of like how file compression works, except we’re dealing with smaller units of data.

DEFLATE is among the most common algorithms for this kind of job. It’s based on two other algorithms (Huffman and LZ77, if you’re a bookworm) and it has a very tried-and-true way of grouping data found within images. Instead of just running through the length of the data and storing multiple instances of a pixel with the same color into a single data unit (known as run-length encoding), it grabs duplicate strings found within the entire code and sets a “pointer” for each duplicate found. Wherever a particular string of data (pixels) is used frequently, it replaces all of those pixels with a weighted symbol that further compresses everything.

Notice how with run-length encoding and DEFLATE, none of the pixels are actually eaten up or forced to change color. Using this method purely results in an image that is identical to the raw original. The only difference between the two lies in how much space is actually taken up on your hard drive!

Lossy Compression

imagecompression-lossy

As the name implies, lossy compression makes an image lose some of its content. When taken too far, it can actually make the image unrecognizable. But lossy doesn’t imply that you’re eliminating pixels. There are actually two algorithms commonly used to compress images this way: transform encoding and chroma subsampling. The former is more common in images and the latter in video.

With transform encoding, an image’s colors are averaged out using a special mathematical formula called discrete cosine transform. The image suffers color loss and may introduce artifacts (weird pixellation at random points of the image) when used excessively. This particular algorithm makes up for its clumsiness with a strong advantage: You can dictate just how much quality you want to remain with the image. With lossless compression, the closest you can come to manipulating quality holistically is by setting the number of colors each image should have.

Chroma subsampling takes another approach. Instead of averaging small blocks of color, which also may affect the brightness of an image, it carefully attempts to keep brightness the same on all areas. This tricks your eyes into not readily noticing any dip in quality. It’s actually great for the compression of animations, which is why it is used more in video streams. That’s not to say that images don’t also use this algorithm.

But wait, there’s more! Google also took a shot at a new lossy algorithm, known as WebP. Instead of averaging color information, it predicts the color of a pixel by looking at the fragments surrounding it. The data that’s actually written into the resulting compressed image is the difference between the predicted color and the actual color. In the end, many of the predictions will be accurate, resulting in a zero. And instead of printing a whole bunch of zeroes, it just compresses all of them into one symbol that represents them. Image accuracy is improved and the compression reduces image size by an average of 25 percent compared to other lossy algorithms, according to Google.

It’s Time For Questions And Discussion!

If you’re new to the world of image files, you’ll probably find at least a little of this information confusing. If you have a question, post it in the comments and we’ll do our best to answer it. Otherwise, you’re welcome to discuss this!

Comments on " How Image Compression Works: The Basics" :

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Related Article

    Edit Google Drive Videos Inside Chrome With WeVideo
    INTERNET

    Edit Google Drive Videos Inside Chrome With WeVideo

    So it’s the day of your big presentation, and it turns out you left your laptop at home. Thankfull

    Show Notification Counts on Pinned Tabs in Chrome
    INTERNET

    Show Notification Counts on Pinned Tabs in Chrome

    Do you use pinned tabs in Chrome as a way to keep up with your email and/or social networking sites

    Forget Everything Else: Exclude Browsing History When Searching via Chrome’s Omnibox
    INTERNET

    Forget Everything Else: Exclude Browsing History When Searching via Chrome’s Omnibox

    As you may already know, in the Google Chrome web browser, the address bar and search bar is combine

    Secure Your Yahoo Account With Second Sign-in and App Password
    INTERNET

    Secure Your Yahoo Account With Second Sign-in and App Password

    It is difficult to be too safe online, and numerous services such as Facebook and Twitter have added

    How to Enable Private Tabs in Firefox
    INTERNET

    How to Enable Private Tabs in Firefox

    To surf the web privately, browsers offer a mode where it doesn’t save visited websites in its his

    How to Add Confirmation Message Before Publishing a Post in WordPress
    INTERNET

    How to Add Confirmation Message Before Publishing a Post in WordPress

    We bloggers are pretty enthusiastic and would love to publish as many articles as possible and as so

    Can People Really Spy on Your Webcam?
    INTERNET

    Can People Really Spy on Your Webcam?

    In December of 2013, many news outlets were reporting that the FBI has had the technology to spy on

    Just How Secure Is Your Bank Account?
    INTERNET

    Just How Secure Is Your Bank Account?

    To most people, a bank account is a symbol of security. They picture armed guards and vaults behind

    About Netverse

    We are a premier digital platform committed to delivering high-quality content to our readers. Our mission is to provide accurate, reliable, and engaging information that adds value to our audience's daily lives.

    Our team consists of experienced content creators and subject matter experts who uphold the highest standards of professionalism. In an era of information overload, we curate content with care, ensuring our users receive only the most relevant and trustworthy information.

    Beyond just reporting facts, we focus on depth and context. Through expert analysis, comprehensive research, and clear presentation, we help our audience gain meaningful insights and make informed decisions.

    We take pride in being a trusted information source for our growing community of readers. Our user-first approach means we continuously adapt to provide content that meets our audience's evolving needs and interests.

    Innovation and excellence drive everything we do. We're committed to improving our platform and services to deliver the best possible experience for our users.