16.7M Possible Colors
3 Bytes per Pixel
90% JPEG Compression

What's Inside an Image File?

Every photo you've ever seen is just millions of numbers arranged in a clever way. Let's crack open image files and see how they really work.

1

More Than Meets the Eye

Every digital image is just a grid of pixels, and every pixel is just three numbers: how much Red, Green, and Blue light to mix together.

Red: 128
Green: 128
Blue: 128
Hex Code:
#808080
64
Pixels Shown
192
Bytes (RGB)
16.7M
Possible Colors
The Math of Color

Each color channel (R, G, B) uses 8 bits, allowing values from 0-255. That's 256 × 256 × 256 = 16,777,216 possible colors! A 1920×1080 photo has over 2 million pixels, each needing 3 bytes. That's 6 MB of raw data - before compression.

Fun Fact: The human eye can distinguish about 10 million colors, so 16.7 million is more than enough for photorealistic images!
2

The JPEG Way: Lossy Compression

JPEG files are small because they throw away details your eyes won't notice. The image is split into 8×8 pixel blocks, then transformed and simplified.

Click a block to see how JPEG processes it

Original 8×8 Block
DCT Coefficients
Quantized (Simplified)
DCT: Discrete Cosine Transform

JPEG converts pixel brightness into frequency patterns. Low frequencies (smooth areas) are kept, high frequencies (sharp edges) are reduced. Your brain fills in the missing detail!

Fun Fact: JPEG was created in 1992 and is still the most widely used image format on the internet, with billions of images created every day!
3

The Price of Compression: Artifacts

When JPEG throws away too much data, you get compression artifacts - blocky areas, color bleeding, and "ringing" around sharp edges.

JPEG Quality Level
Low High
80%
45 KB
File Size
15:1
Compression
Good
Quality
Original
Compressed (Quality: 80%)
Difference (10× enhanced)
Fun Fact: Re-saving a JPEG causes "generation loss" - each save adds more artifacts. Never edit and re-save JPEGs repeatedly!
4

The PNG Way: Lossless Perfection

PNG uses lossless compression - it makes files smaller without losing ANY data. The decompressed image is bit-for-bit identical to the original.

JPEG

48 KB size
Lossy type

PNG

156 KB size
Lossless type
How PNG Compresses

PNG uses filtering (predicting pixel values from neighbors) and DEFLATE compression (finding repeated patterns). It's the same algorithm used in ZIP files! Great for graphics, terrible for photos.

100%
Quality
2-3×
Larger than JPEG
Yes
Transparency
Fun Fact: PNG was created in 1996 as a patent-free replacement for GIF. The name originally stood for "PNG's Not GIF"!
5

Inside the File: Headers & Metadata

Image files start with magic bytes that identify the format, followed by metadata about the image, and finally the actual pixel data.

JPEG File Structure:
FF D8 ← JPEG magic bytes (Start of Image)
FF E0 00 10 4A 46 49 46 ← APP0 marker + "JFIF"
FF E1 ... ← EXIF metadata (camera info, GPS, etc.)
FF DB ... ← Quantization tables
FF C0 ... ← Image dimensions, color info
FF DA ... image data ... ← Compressed pixel data
FF D9 ← End of Image
Privacy Warning!

Photos from your phone often include GPS coordinates! Before sharing images online, consider stripping EXIF data. Many social media sites do this automatically, but not all.

Fun Fact: In 2012, antivirus pioneer John McAfee was located by authorities because a photo posted online contained GPS metadata revealing his location in Guatemala!
6

Choose Your Format

Different formats excel at different tasks. Here's when to use each one.

Format Type Best For Transparency Animation
JPEG Lossy Photos, realistic images No No
PNG Lossless Graphics, logos, screenshots Yes No
GIF Lossless Simple animations, memes 1-bit only Yes
WebP Both Web images (modern) Yes Yes
SVG Vector Icons, logos, illustrations Yes Yes
Fun Fact: WebP was created by Google in 2010 and can be 25-34% smaller than JPEG at the same quality. It's now supported by all major browsers!

File Decoded!

You've uncovered the secrets hidden inside image files.

0
Pixels Explored
0
Formats Learned
0
Time Exploring

RGB Values

Every pixel is stored as three numbers (0-255) for Red, Green, and Blue.

JPEG Compression

JPEG saves space by discarding details your eyes barely notice, but this causes artifacts.

PNG Perfection

PNG compresses without losing any data - perfect for graphics, logos, and screenshots.

Right Tool

Photos → JPEG. Graphics/logos → PNG. Animations → GIF. Modern web → WebP.

Ready to Create?

Put your new knowledge into practice!

More Discoveries

Suggest a Correction