File Compression Explained: How It Works and Why It Matters
Your phone takes a 12 MP photo that weighs 8 MB. You run it through a compression tool and it drops to 800 KB — ten times smaller — and looks exactly the same. Where did those 7.2 MB go? Understanding compression helps you make better decisions about file quality, storage, and sharing.
What is file compression?
Compression reduces file size by encoding data more efficiently. The core idea: most files contain redundant or predictable information that can be represented in fewer bytes.
A blue sky in a photo, for example, contains millions of pixels that are nearly identical shades of blue. Instead of storing each pixel individually, compression algorithms store the pattern once and reference it. The file gets smaller; the image looks the same.
Lossy vs. lossless compression
Lossless compression
No data is lost. The decompressed file is identical, bit-for-bit, to the original. Every detail is preserved.
- Formats: PNG, GIF, ZIP, PDF (text/vector content), FLAC
- How it works: Algorithms find patterns and redundancies, encoding them more efficiently without discarding anything.
- Typical reduction: 20-60% depending on content
- Best for: Text documents, source code, screenshots, diagrams, anything where exact reproduction matters.
Lossy compression
Some data is permanently discarded to achieve much smaller file sizes. The algorithm removes information that humans are unlikely to notice — subtle colour variations, high-frequency detail, quiet sounds in audio.
- Formats: JPG, WebP (lossy mode), MP3, MP4
- How it works: Perceptual models determine what the human eye (or ear) is least likely to miss, and those details are removed.
- Typical reduction: 60-95% depending on quality setting
- Best for: Photos, video, audio, any content where a small quality trade-off is acceptable.
How image compression works
JPG compression (lossy)
- The image is divided into 8x8 pixel blocks.
- Each block is transformed using a mathematical operation (DCT — discrete cosine transform) that separates important visual information from fine detail.
- The fine detail (high-frequency data) is reduced or removed based on the quality setting.
- The result is encoded efficiently.
Higher quality = more detail preserved = larger file. Lower quality = more detail removed = smaller file.
PNG compression (lossless)
- The image is filtered row by row to make pixel values more predictable.
- The filtered data is compressed using DEFLATE (the same algorithm as ZIP).
- No information is lost — every pixel is preserved exactly.
PNG files are larger than JPG for photos, but they preserve transparency and sharp edges perfectly.
How PDF compression works
PDFs are containers that can hold text, vector graphics, images, fonts, and metadata. Each component is compressed differently:
- Text and vectors: Already compact. Lossless compression (DEFLATE) reduces them further.
- Embedded images: The biggest contributor to file size. Compress PDF re-compresses these images at an optimised quality level.
- Fonts: Subset embedding includes only the characters used, reducing font data.
- Metadata: Creation date, author, revision history — often unnecessary and safely removed.
Choosing the right compression level
| Use case | Compression type | Quality | Tool |
|---|---|---|---|
| Photo for social media | Lossy (JPG) | Medium-high | Compress Image |
| Screenshot for documentation | Lossless (PNG) | Maximum | No compression needed |
| PDF for email attachment | Lossy (images) | High | Compress PDF |
| Photo for printing | Lossy (JPG) | Maximum | Compress Image (light) |
| Archival / legal document | Lossless | Maximum | Avoid lossy compression |
Common compression mistakes
Compressing an already-compressed file
Re-compressing a JPG introduces additional quality loss with diminishing size reduction. If the file is already compressed, further compression makes it worse, not smaller.
Using lossy compression on text or diagrams
JPG compression creates visible artefacts around sharp edges and text. Use PNG for screenshots, diagrams, and text-heavy images.
Over-compressing for the medium
A photo destined for a billboard needs higher quality than one for a social media post. Match the compression level to how the image will be viewed.
Frequently asked questions
Can I undo compression?
Lossless compression: yes, the original data is fully recoverable. Lossy compression: no, the discarded data is permanently gone. Always keep the original file.
Does compressing a PDF affect text quality?
No. Text in a PDF is stored as vector data, which is not affected by image compression. Only embedded images are re-compressed.
What is the difference between compressing and resizing?
Compression reduces file size by encoding data more efficiently (and optionally discarding detail). Resizing reduces pixel dimensions. Both reduce file size, but through different mechanisms.
Why is my PNG larger than my JPG?
PNG uses lossless compression, which preserves every pixel. JPG uses lossy compression, which discards detail. For photos, JPG produces much smaller files. For screenshots and diagrams, PNG is preferred despite the larger size.
Compression tools: Compress Image, Compress PDF, Resize Image, or browse all converters.
Convert a file for free
Every tool on ImgToPDFConvert runs in your browser — no signup, no watermark, files discarded instantly.
Browse all toolsKeep reading
Batch File Conversion: How to Convert Multiple Files at Once
Save time by converting multiple images, PDFs, and documents in one go. Tips for batch workflows using free online tools.
How to Convert WebP to JPG or PNG (And Why You Need To)
Convert WebP images to JPG or PNG for compatibility with apps, websites, and software that don't support Google's modern image format.
Digital Signatures on PDFs: What They Are and How They Work
Understand the difference between electronic signatures and digital signatures on PDFs. Learn how digital certificates, validation, and tampering detection work.