Skip to main content

compression

Lossy vs Lossless: What Actually Happens When You Convert a File

robinhood-projects11 min read

Compress PDF β€” Free Online

Reduce your PDF file size in seconds. Choose Low, Medium, or High quality β€” text and vectors stay sharp, only embedded images are downsampled. No signup required.

Use Tool β†’

Video Compressor

Reduce video file size while maintaining acceptable quality

Use Tool β†’

Lossy vs Lossless: What Actually Happens When You Convert a File

You have heard the terms before β€” probably when saving a JPEG, exporting audio, or shrinking a video. Lossy. Lossless. The words sound self-explanatory, but most explanations stop there, leaving the actual mechanics a mystery.

This article closes that gap. You will learn what each compression type does at a mechanical level, why it matters for real files you work with every day, and how to choose correctly depending on whether you are archiving, publishing, or editing.

The Core Difference in One Paragraph

Lossless compression reorganises data so it takes up less space β€” but every single bit of the original can be recovered exactly. Lossy compression achieves much smaller files by permanently discarding data the human perceptual system is unlikely to notice. Once that data is gone, it cannot be recovered. The trade-off is always the same: lossy gives you smaller files, lossless gives you identical reconstructions.

How Lossless Compression Works

Think of lossless compression the way you would think of a smart shorthand. Instead of writing "AAAAAAAAAA" ten times, you write "10Γ—A". The information content is identical; the representation is shorter. When you decompress, you expand the shorthand back to the original.

Real lossless algorithms are more sophisticated, but the principle holds. They find and exploit statistical redundancy β€” patterns that repeat, long runs of similar values, sequences that can be predicted from what came before. Common techniques include:

  • Run-length encoding β€” compresses repeated identical values (useful for solid-colour areas in images).
  • Huffman coding β€” assigns shorter bit codes to more frequent symbols, longer codes to rare ones.
  • LZ77/LZ78 (Deflate) β€” finds repeated sequences anywhere in the data and replaces later occurrences with back-references.

None of these techniques throw anything away. A PNG compressed with Deflate, a FLAC audio file, or a ZIP archive can all be decompressed to produce a bit-for-bit identical copy of the original. That is what "lossless" means in a strict technical sense.

How Lossy Compression Works

Lossy algorithms take a different approach: they exploit the limits of human perception to discard data that most people will never miss.

The key insight is that your visual system and auditory system are not equally sensitive to everything. Your eyes are far better at detecting changes in brightness than changes in colour. Your ears are much more sensitive to frequencies around 1–4 kHz (speech) than to very high or very low frequencies. Lossy codecs take advantage of these limits aggressively.

DCT and JPEG β€” the Image Case

JPEG compression starts by dividing an image into 8Γ—8 pixel blocks. Each block undergoes a Discrete Cosine Transform (DCT), which converts the block's pixel values into a set of frequency components β€” essentially how much fine detail versus broad gradients exist in that block.

Then the quantisation step throws away the high-frequency components. The amount discarded is controlled by the quality setting. At JPEG quality 85, the quantisation is gentle β€” you lose subtle fine-grain texture that the eye would not catch. At quality 40, the quantisation is aggressive β€” the blocky artefacts become visible because coarse structure is being approximated too roughly.

A JPEG at quality 85 typically achieves around 10:1 compression relative to the raw uncompressed image. The same image at quality 60 might hit 20:1, but artefacts will be visible on close inspection.

Psychoacoustic Models and MP3

MP3 uses a psychoacoustic model to decide what audio data to throw away. It analyses each short slice of audio and identifies:

  • Frequencies that are too quiet to hear above louder nearby frequencies (masking).
  • Very high and very low frequencies where the human ear is least sensitive.
  • Fine detail during loud transients where the ear's temporal resolution is temporarily reduced.

Those components are encoded at much lower precision or dropped entirely. At 320 kbps, the result is perceptually identical to CD audio for most listeners. At 128 kbps, a trained ear can detect artefacts in certain tracks β€” pre-ringing on sharp transients, for example, or a slightly "watery" sound on cymbals.

Format-by-Format Breakdown

Images

JPEG β€” Lossy

JPEG is the dominant format for photographs. The DCT-based codec described above is designed specifically for photographic content β€” smooth gradients, complex textures β€” where the discarded high-frequency data is genuinely hard to see.

JPEG is a poor fit for line art, text, and screenshots. Hard edges and solid colours produce visible "ringing" artefacts because the DCT algorithm attempts to approximate sharp transitions with smooth frequency components and fails.

Typical compression at quality 85: 10:1. At quality 75: 15–20:1 with minor, usually invisible, loss.

PNG β€” Lossless

PNG uses Deflate compression on the raw pixel data, with a pre-processing step called filtering that improves compressibility by encoding each pixel as a delta from its neighbours rather than an absolute value. Nothing is discarded. A decompressed PNG is pixel-perfect.

PNG compresses photographs poorly relative to JPEG β€” a photograph as a PNG might be 3Γ— the size of the same photo as a JPEG at quality 85. But for screenshots, diagrams, and anything with text or sharp edges, PNG is the correct choice.

WebP β€” Both Modes

WebP supports lossy and lossless modes explicitly. In lossy mode it uses a variant of the VP8 video codec and typically achieves 25–35% smaller files than JPEG at equivalent visual quality. In lossless mode it outperforms PNG on photographs but is comparable or slightly worse on simple graphics. It also supports alpha transparency in both modes, which JPEG cannot do at all.

Audio

WAV / AIFF β€” Uncompressed

WAV and AIFF store raw PCM audio. There is no compression β€” every sample is stored exactly. A single minute of stereo audio at CD quality (44.1 kHz, 16-bit) occupies roughly 10 MB. These are the formats used in professional audio production when no compromise is acceptable.

FLAC β€” Lossless

FLAC (Free Lossless Audio Codec) applies lossless compression to PCM audio and achieves typical reductions of 40–60%. A minute of CD-quality audio becomes 4–6 MB instead of 10 MB. Every decoded sample is identical to the original. FLAC is the standard archival format for high-quality audio collections.

MP3 β€” Lossy

MP3 uses the psychoacoustic model described above. At 320 kbps, the file is about 1 MB per minute β€” a 10Γ— reduction from uncompressed. At 128 kbps, it's around 1 MB per 4 minutes, with perceptibly lower quality on demanding content.

AAC is a more modern lossy format that achieves equivalent quality to MP3 at about 70–80% of the bitrate. Apple Music and most streaming platforms use AAC.

Video

H.264 (AVC) β€” Lossy

H.264 is the most widely deployed video codec. It combines DCT-based spatial compression within each frame (similar to JPEG) with temporal compression across frames β€” encoding only what changed from the previous frame rather than the full picture every time.

A two-hour 1080p film compressed with H.264 at a typical streaming bitrate (4–8 Mbps) is roughly 4–8 GB. The equivalent uncompressed 1080p at 24 fps would be several hundred gigabytes. The compression ratio is enormous β€” and at reasonable bitrates, perceptual quality is excellent.

H.265 (HEVC) and AV1 improve on H.264 by 30–50% at the same visual quality level, at the cost of significantly higher encoding complexity.

Lossless Video Codecs

Lossless video exists β€” formats like Apple ProRes 4444, FFV1, and Ut Video are used in professional editing pipelines. File sizes are massive. ProRes 4444 at 4K runs to several terabytes per hour of footage. These formats exist for production, not delivery.

Documents

PDF compression is somewhat different in character from image or audio compression, because a PDF is a structured document containing a mix of vector graphics, fonts, embedded images, and metadata β€” not a single uniform media stream.

PDF stream compression applies Deflate (lossless) to the text and vector data in the document. The text and layout geometry are fully recoverable. Embedded images within a PDF may be JPEG (lossy) or other formats β€” and those images are subject to the same trade-offs described above.

When you compress a PDF, the primary levers are: re-compressing embedded images at lower JPEG quality, downsampling high-resolution images that are larger than needed for screen or print, and removing embedded metadata. The text and structure of the document are never degraded.

The Generation Loss Problem

This is the practical consequence most people discover accidentally.

When you open a JPEG, edit it, and save it again as a JPEG, you have re-compressed an already-lossy file. The quantisation step runs again on data that has already been quantised. Each generation β€” each save β€” compounds the loss. After five or six re-saves, the degradation becomes clearly visible: smeared edges, blockiness in flat areas, colour banding.

The same effect applies to video. Re-encoding an H.264 file as H.264 at the same bitrate will produce noticeably worse output than the original encode from a lossless source.

The correct workflow is always:

  1. Keep lossless (or uncompressed) originals for anything you will edit repeatedly.
  2. Apply lossy compression only at the final export step.
  3. Never re-save a lossy file in a lossy format unless you accept accumulating quality loss.

This is why camera RAW files, WAV audio tracks in a DAW, and ProRes video in an editing timeline all exist: they are the lossless working copies that get exported to lossy formats only at the end.

Format Comparison Table

FormatTypeTypical CompressionBest Use Case
PNGLossless2–5Γ— vs rawScreenshots, graphics, icons, anything with text
JPEG (q85)Lossy~10Γ— vs rawPhotographs for web or print
JPEG (q60)Lossy~20Γ— vs rawThumbnails, previews where quality is secondary
WebP lossyLossy~13Γ— vs rawWeb photographs, 25–35% smaller than equivalent JPEG
WebP losslessLossless~3Γ— vs rawWeb graphics where PNG compatibility is not required
FLACLossless~2Γ— vs WAVAudio archival, lossless music distribution
MP3 (320 kbps)Lossy~10Γ— vs WAVAudio distribution, streaming
MP3 (128 kbps)Lossy~24Γ— vs WAVPodcasts, voice, low-bandwidth streaming
H.264 (8 Mbps, 1080p)Lossy~100Γ— vs rawWeb video delivery, streaming
ProRes 4444Lossless~5Γ— vs rawVideo production and editing
ZIP / DeflateLossless2–10Γ— (varies)General files, documents, source code

When to Use Lossy vs Lossless

Use lossless when:

  • You are archiving original files you may need to edit later.
  • The content contains text, line art, or sharp geometric edges.
  • You are in the middle of a production workflow (editing audio, video, or images).
  • Quality is non-negotiable β€” medical imaging, legal documents, master recordings.

Use lossy when:

  • You are delivering content to end users over the web or mobile.
  • File size is a hard constraint and the content is photographic or cinematic.
  • The audience will view the content at typical screen brightness and listening conditions, not in a critical listening environment.

The "good enough" threshold:

At JPEG quality 85 on photographic content, the artefacts are invisible to the vast majority of viewers at normal viewing distances. At MP3 320 kbps, the degradation is inaudible on standard consumer headphones to virtually everyone. Below quality 70 for JPEG and below 192 kbps for MP3, you may start to see or hear differences on critical content β€” though the file size savings may still justify it depending on the use case.

The practical implication: for web delivery, lossy at high quality settings is the right default. The size difference between lossless and lossy at quality 85 is enormous (often 5–10Γ—), while the quality difference is negligible. There is little reason to serve lossless images or audio to a website visitor.

Putting It Into Practice

If you need to compress an image, start with quality 80–85 for photographs and lossless mode for graphics. You will get the majority of the file size benefit with no visible quality change.

For video, the trade-offs are similar but the stakes are higher because re-encoding video is time-consuming and the generation loss is more pronounced. If you need to compress a video, work from the highest-quality source you have, and export once to your target format rather than re-encoding a compressed file.

The deeper principle behind all of these decisions is the same: understand whether your file contains data that can be safely discarded (perceptual content delivered for consumption) or data that must be preserved (working files, archives, anything you will process further). That distinction maps almost perfectly onto the lossy/lossless choice.

For a deeper look at the image compression side of this, see the image compression guide which covers format-specific quality settings, resizing strategies, and browser format support in more detail.


Compress your files now: Images β€” PDFs β€” Videos