Skip to main content

HOW THE PICTURE IS COMPRESSED?

 🎨 How a Picture is Compressed (JPEG) – Simply Explained



Imagine you have a big photo and you want to make the file size smaller.
JPEG compression does this in smart steps:


Step 1: Separate Brightness and Color

  • Your eyes care much more about brightness than precise color.

  • So, the image is split into:

    • Brightness layer (Y)

    • Color layers (Cb and Cr)

👉 Why? Because we can *reduce color detail without you noticing much.


Step 2: Reduce Color Detail

  • The color layers are shrunk in resolution (less pixels).

    • For example, 4 pixels of color can be replaced by 1 average color.

  • This alone saves a lot of data.


Step 3: Break Into Small Blocks

  • The picture is cut into small 8×8 pixel squares.

    • Think of cutting a photo into little tiles.


Step 4: Turn Pixels Into Frequencies

  • Each 8×8 block is converted into frequencies using math called DCT (Discrete Cosine Transform).

    • This shows:

      • Big changes (like edges)

      • Small changes (tiny details)

👉 Analogy: Like splitting music into bass and treble.


Step 5: Remove Tiny Details

  • JPEG reduces or removes small details your eye hardly sees.

    • This is called quantization.

    • Big numbers (important details) stay.

    • Small numbers (tiny variations) get rounded or set to zero.

👉 This is where you lose some quality.


Step 6: Reorder the Data

  • The remaining numbers are arranged in a zigzag line, from most to least important.


Step 7: Compress Repeats

  • The data is squeezed further by:

    • Run-length encoding: Repeats are stored as “repeat 0 ten times.”

    • Huffman coding: Frequent numbers get shorter codes.


Step 8: Save the Compressed File

  • The final result is a much smaller file.

When you open the picture, your computer reverses these steps to show the image again.


💡 In One Sentence:

JPEG compresses pictures by:

  • reducing color detail,

  • splitting into blocks,

  • removing fine details you don’t notice,

  • and storing the data very efficiently.


Analogy:

Imagine describing a carpet:

  • Original way: You name the color of every thread.

  • JPEG way: You say:

    • “Mostly red.”

    • “Some blue patches here.”

    • “Tiny dots—ignore them.”
      This saves space while the carpet still looks the same.


📊 Quick Comparison:

Format Lossy or Lossless? How it saves space
JPEG Lossy Removes small visual details
PNG Lossless Finds repeating patterns
GIF Lossless (but limited colors) Reduces colors (max 256)
WebP Both Combines modern techniques