Almost every photo, song, video and web page you use has been compressed, because data is expensive to store and slow to send. Compression rewrites information more efficiently by spotting patterns and repetition, the way a shorthand note captures a long sentence. Some methods give back every bit exactly, while others quietly throw away detail your eyes and ears would never miss. Either way, no method can shrink everything forever: every piece of data has a floor set by how unpredictable it really is.
What Compression Saves You
Connected systems, such as networks of sensors reporting to a central server, create huge demand for both bandwidth and storage.1Future Generation Computer Systems. A spatiotemporal data compression approach with low transmission cost and high data fidelity for an air quality monitoring system Shrinking the data before sending it lowers transmission cost and avoids paying for ever-larger storage.1Future Generation Computer Systems. A spatiotemporal data compression approach with low transmission cost and high data fidelity for an air quality monitoring system
You meet this all day. A zip file emailed to a colleague is compressed on your end and unpacked on theirs. Web servers often compress pages before they reach your browser. Streaming video arrives compressed, which is why quality drops when your connection weakens. Your phone saves photos as compressed images by default.
Compression is a trade, not a free gift. Choosing a compressor means balancing how small files get, how fast it runs, how much energy it uses and how much quality is kept.2arXiv. To Compress or Not To Compress: Energy Trade-Offs and Benefits of Lossy Compressed I/O Methods that squeeze hardest are often slower, while faster ones save less space.3Future Generation Computer Systems. Striking the balance between speed and compression ratio: A fast bit-grouping algorithm and adaptive compressor selection for scientific data So the format on your device was picked for its job, such as quick web loading or long-term archiving.
Speed matters as much as size because a compressed file still has to be turned back into usable data before a program can work with it, and that takes processor time. A slow unpacking method can leave you waiting on a large download or archive even though the file was small to send. Video streaming is the strictest case: each stretch of video must be unpacked before the moment it plays, or the picture stutters. Backups are the opposite. Nobody is waiting on them, so a slower method that saves more space can be the better choice.
How Data Shrinks Without Losing Anything
Lossless compression rebuilds the original data exactly, bit for bit. That is essential for documents, programs and spreadsheets, because a single changed character can corrupt a program or alter a number in a bank record.
The most common family of methods keeps a running dictionary of recently seen strings of data.4Duke University. Algorithms in the Real World: Data Compression III When a string repeats, the compressor writes how far back the earlier copy is, how long it runs, and the next new character.4Duke University. Algorithms in the Real World: Data Compression III A phrase that appears 50 times in a document is stored once plus 49 short pointers. Brotli, a format used on the web, is built on this approach and was designed to replace the older Gzip.5ACM Transactions on Information Systems. Brotli
Ordinary writing shrinks well because language repeats itself constantly, with words like “the” and whole phrases coming back again and again. Unzipping follows each pointer to the earlier text and copies it out, rebuilding every character exactly as it was.
Ordered data can be stored as counts or differences. A long run of identical values becomes the value plus a count, so a million “true” entries in a row turn into one pair.6ClickHouse. Database compression: encodings, codecs and ratios A steadily rising list like 1000, 1001, 1002 can be stored as 1000 followed by the small differences 1, 1.6ClickHouse. Database compression: encodings, codecs and ratios Small differences fit into far fewer bits than full numbers. Storing differences between differences cut timestamp storage by over 95% in one large company’s monitoring data.6ClickHouse. Database compression: encodings, codecs and ratios
Results vary because lossless methods only profit from repetition. A log file where nearly every line looks like the one before it can shrink dramatically, since most of it becomes pointers to earlier lines. A file of random-looking data has few repeats to point back to, so it barely shrinks. Two files of the same size can therefore zip to very different sizes.
Short Codes for Common Symbols
The idea is older than computers. Morse code gave the most common English letters, like e and a, the shortest signals, and rare ones like q and z longer ones.7Encyclopedia of Information Systems. Data Compression Messages took less time to send on average.7Encyclopedia of Information Systems. Data Compression
Huffman coding builds the shortest-on-average codes from letter frequencies. It repeatedly pairs up the two least common symbols until everything joins into one tree.8Journal of Computer Science Education / Lecture Notes. Huffman Coding Rare symbols end up deep in the tree and get long codes, while common ones near the top get short codes.8Journal of Computer Science Education / Lecture Notes. Huffman Coding
Codes must not blur together. If one symbol’s code were the first part of another’s longer code, a reader seeing those bits couldn’t tell whether a symbol had ended or was still going. Morse gets around this with pauses between letters, which costs extra time. Huffman coding makes sure no code begins another, so a stream of bits can be read without gaps or separators.9Wikipedia. Huffman coding A computer can then read from start to finish in a single pass, always knowing where each symbol ends.
Newer methods squeeze closer to the limit at good speed. Arithmetic coding uses near-exact probabilities and gets very close to the theoretical limit, but is slower to run.10arXiv. Asymmetric numeral systems: entropy coding combining speed of Huffman coding with compression rate of arithmetic coding A newer method matches that compression while decoding about 50% faster than Huffman coding in one implementation.10arXiv. Asymmetric numeral systems: entropy coding combining speed of Huffman coding with compression rate of arithmetic coding
Short codes also team up with repeat-spotting. Many common formats first replace repeated strings with pointers, then give the most frequent pointers and letters short codes. One step removes repeated stretches; the other removes the waste of giving every symbol the same length. Formats behind zip files and web pages combine both, which is why they do better than either idea alone.
The Limit No Compressor Can Beat
Claude Shannon showed there is a minimum average number of bits per symbol, set by how unpredictable the data is, below which data can’t be compressed without almost certainly losing information.11Wikipedia. Shannon’s source coding theorem Methods can get arbitrarily close to that floor.11Wikipedia. Shannon’s source coding theorem12PubMed Central. The Compression Optimality of Asymmetric Numeral Systems13arXiv. A tutorial on the range variant of asymmetric numeral systems
A coin makes it concrete. A fair coin is fully unpredictable, so each flip needs a whole bit to record, and no clever scheme can do better. A coin that lands heads nine times in ten is more predictable, so its results can be written in fewer bits on average, using short codes for the likely outcome. That floor depends on predictability, and compression exploits it.
For your files, predictable data compresses well, while unpredictable data barely shrinks. Zipping an already-compressed photo, video or zip file saves almost nothing, because its patterns have been squeezed out, and the result can come out slightly larger because the extra packaging adds a little overhead. And no tool can shrink every file losslessly, so any claim that one does is false.
Throwing Away What You Won’t Notice
Lossy compression permanently removes information to reach much smaller sizes. Audio formats use models of human hearing to find which parts of a sound can be dropped or simplified without an audible difference.14Wikipedia. Psychoacoustics Compressed music files are often a tenth to a twelfth the size of studio masters.14Wikipedia. Psychoacoustics
Photos get the same treatment. JPEG works in these steps:
- It converts colours into brightness and colour channels.15arXiv. JPEG Image Compression using the Discrete Cosine Transform: An Overview, Applications, and Hardware Implementation
- It stores colour at lower resolution, since eyes are less sensitive to colour detail.15arXiv. JPEG Image Compression using the Discrete Cosine Transform: An Overview, Applications, and Hardware Implementation
- It describes small blocks of the image as mixes of smooth and fine patterns.15arXiv. JPEG Image Compression using the Discrete Cosine Transform: An Overview, Applications, and Hardware Implementation
- It rounds off the fine patterns, which is where detail is lost.15arXiv. JPEG Image Compression using the Discrete Cosine Transform: An Overview, Applications, and Hardware Implementation
- It packs the result with lossless short codes.15arXiv. JPEG Image Compression using the Discrete Cosine Transform: An Overview, Applications, and Hardware Implementation
A quality slider controls that rounding. Lowering it makes the rounding more aggressive, so more detail is thrown away. The file shrinks, but blocky patches and smeared edges start to appear, especially around sharp lines and text. Re-saving a JPEG repeatedly applies the rounding again each time, so it loses a little more with every save.
Video saves most by not repeating what stays still. Video formats predict each frame from earlier ones by tracking how blocks of pixels move.16arXiv. Deep motion estimation for parallel inter-frame prediction in video compression Only the movement and the small differences need storing, not each whole frame. Block-based tracking struggles with rotation, warping and complex motion.172019 Data Compression Conference (DCC). Deep Frame Interpolation for Video Compression That is why fast scenes and confetti look blocky: they are hard to predict from the previous frame, and with limited bandwidth the encoder must discard more detail. Still scenes stay sharp because little changes.
Use lossless for documents, code and originals you will edit. Lossy suits sharing and streaming, and it pays to keep an original before heavy lossy saving.
How Quality Loss Is Judged
Format designers test quality with computer scores and with people rating images.18PubMed Central. Review of Image Quality Assessment Methods for Compressed Images Computer scores are fast and cheap, but human ratings, though slow and costly, remain the gold standard.19SSRN. Review of the Image Quality Assessment Methods for the Compressed Images The JPEG committee chose a set of scores, including ones used by streaming services like VMAF, because they best matched human judgment.20PubMed Central. Subjective Assessment of Objective Image Quality Metrics Range Guaranteeing Visually Lossless Compression
A good score can still look bad. Simple scores compare images pixel by pixel, and can rate a picture highly even when it has flaws the eye finds obvious. People pay more attention to faces and edges than to flat backgrounds, so damage there matters more than raw numbers suggest. Newer scores try to model human vision, which is part of why they track human ratings better, but they remain approximations.
You can judge for yourself. View the image or video at the size you will really use it, since flaws that show when zoomed in may never matter on a phone screen. Zoom in on edges and smooth gradients such as skies, where blockiness and banding show up first. For music, listen on decent headphones and watch for swishy or smeared cymbals, a common sign of heavy compression. Compare against the original when you have it, since flaws are far easier to spot side by side.
Where Compression Is Heading
AI image compressors learn how to map a picture into a compact form and back, beating many traditional formats on quality.21IEEE Xplore. Rate-Distortion Optimized Learning-Based Image Compression using an Adaptive Hierachical Autoencoder with Conditional Hyperprior Learned motion prediction has outperformed the standard H.264 and H.265 video formats at low data rates.16arXiv. Deep motion estimation for parallel inter-frame prediction in video compression For ordinary users, that could mean sharper video calls on weak connections, because a learned model can spend its limited bits more cleverly, and photo libraries that take less space at the same visible quality. These methods demand more computing power than older formats, so how soon you see them depends on whether your device has chips that can run them efficiently.
Hardware and smarter software are making compression faster. New NVIDIA chips include a dedicated decompression engine that takes the job off the main processor.22NVIDIA Technical Blog. Speeding Up Data Decompression with nvCOMP and the NVIDIA Blackwell Decompression Engine Some systems search or process compressed data directly without unpacking it first.23ACM Transactions on Information Systems. A text compression scheme that allows fast searching directly in the compressed file24Proceedings of the 2022 International Conference on Management of Data. CompressDB: Enabling Efficient Compressed Data Direct Processing for Various Databases

