General knowledgeIn depthAsked by Anonymous23 Oct 2026, 11:10 AM ISTUpdated
In one line
Compression makes files smaller by removing extra or repeated information, so they take up less space.
The rule
Compression is the process of reducing the size of a file by encoding its data more efficiently, often by removing unnecessary or repeated parts.
There is no single formula, but two main types:
Lossless compression: No information is lost. You can get back the original file exactly.
Lossy compression: Some information is thrown away. The file is smaller, but you can't get back the exact original.
Let's understand it simply
Imagine you are writing notes in your notebook. If you write every word fully, your notebook fills up fast. But if you use short forms like "b/w" for "between" or "w/" for "with", you save space. This is like lossless compression—you can still get the full meaning back.
Now, think about when you tell a friend about a movie. You don't repeat every line; you just share the main story. Some details are left out, but your friend still understands. This is like lossy compression—some information is lost, but the main idea is there.
Lossless vs Lossy Compression
Lossless
Lossy
What happens
No information lost
Some information lost
Examples
ZIP, PNG
JPEG, MP3
Can get back original?
Yes
No
Used for
Documents, some images
Photos, music, videos
How it works
Find patterns or repeats: The computer looks for repeated parts, like the same color in an image or the same sound in music.
Replace repeats with shortcuts: It uses codes or shortcuts for these repeats. For example, "red, red, red" becomes "3 reds".
Remove less important details: In lossy compression, it throws away tiny details that humans may not notice, like very quiet sounds or small color changes.
Save the new, smaller file: The file now takes up less space on your phone or computer.
Reverse the process to open: When you want to see or hear the file, the computer undoes the shortcuts. In lossless, you get the exact original. In lossy, you get a close version.
How image compression works
Find repeated colors or patterns
Replace repeats with codes
Remove tiny details (if lossy)
Save the smaller file
Reverse when opening (if possible)
The story behind it
Compression started when computers had very little storage and slow internet. In the 1940s, Claude Shannon, an engineer, worked on how to send messages using as few bits as possible. Later, as music and images became digital, people invented special ways to shrink these files. For example, the JPEG format for images was created in the 1990s by a group called the Joint Photographic Experts Group. MP3 for music was made by engineers in Germany in the 1990s to make songs small enough to send over the internet. One fun fact: the first song ever compressed to MP3 was "Tom's Diner" by Suzanne Vega!
Where you see it in real life
WhatsApp images: When you send a photo, WhatsApp compresses it so it sends faster. The image may lose some sharpness.
YouTube videos: Videos are compressed so they load quickly, even with slow internet. Some details may look blurry.
MP3 songs: Songs you download are much smaller than the original studio files. Some background sounds are removed.
ZIP files: When you "zip" homework to email it, the computer squeezes the files using lossless compression.
Scanned documents: Scanners use compression so a 10-page PDF is easy to send.
TV and radio: Digital TV and FM radio use compression to fit more channels in the same space.
Why it matters
Saves storage: You can keep more photos, songs, and videos on your phone or pen drive.
Faster sharing: Files upload and download quickly, even with slow internet.
Less data cost: Smaller files mean you use less mobile data.
Needed for streaming: Services like Netflix, Spotify, and YouTube depend on compression to work smoothly.
Worked example
Let's say you have a simple image:
The image has 10 pixels: red, red, red, green, green, blue, blue, blue, blue, blue.
Lossless compression (Run-Length Encoding):
Given: Image = [red, red, red, green, green, blue, blue, blue, blue, blue]
Step 1: Find repeats: 3 reds, 2 greens, 5 blues
Step 2: Write as codes: (3,red), (2,green), (5,blue)
Step 3: Store only the codes, not every pixel
Step 4: File is now much smaller
Lossy compression (MP3 for music):
Given: Song has sounds humans can't hear (very high or low)
Step 1: Find parts of sound that are hard to hear
Step 2: Remove those parts
Step 3: Store only the main sounds
Step 4: File is smaller, but sounds almost the same to most people
Common mistakes
Thinking all compression is lossless: Some types (like JPEG, MP3) lose information. You can't get back the exact original.
Believing compression always makes files tiny: Some files, like already compressed images, can't be shrunk much more.
Assuming quality never drops: Lossy compression can make photos blurry or music sound odd if compressed too much.
Confusing ZIP with JPEG/MP3: ZIP is lossless (for any file), JPEG/MP3 are lossy (for images/music only).
Remember it
Compression is like packing your bag smartly—remove what you don't need, fold the rest, and you can carry more!
Check yourself
What is the main difference between lossless and lossy compression?
Lossless keeps all information; lossy removes some details and can't get back the exact original.
Why do apps like WhatsApp compress images before sending?
To make the file smaller, so it sends faster and uses less data.
Give one example of lossless and one of lossy compression.
Lossless: ZIP file. Lossy: JPEG photo.
Why can too much compression make a song or photo sound or look bad?
Because lossy compression removes details, and too much removal makes quality drop.
Quick recap
Compression reduces file size by removing repeats or less important data.
Lossless compression keeps all original information; lossy does not.
Images (JPEG) and music (MP3) often use lossy compression.
Compression helps save storage, speed up sharing, and cut data costs.