# What is Lossy Compression?

Lossy compression reduces file size by irreversibly discarding information considered less important to perceived quality. Decompression produces an approximation rather than the exact original data.

Source samples

Transform, quantize, entropy-code

Smaller file that decodes to an approximation

Quantization discards detail that decoding cannot restore.

<span aria-hidden="true" id="how-it-works"></span>

## How Lossy Compression works

A lossy encoder typically transforms samples into a representation in which perceptually less important detail can be isolated, quantizes that detail coarsely or drops it, and entropy-codes what remains. The quantization step discards precision that decoding cannot restore. JPEG illustrates the pattern: its DCT-based processes quantize frequency coefficients with a quantization table, the example tables in the standard are based on psychovisual thresholds, and encoders commonly also store color at lower resolution than brightness. Video encoders add rate control, which decides how much quantization each part of the picture receives; x265, for example, raises or lowers per-block quantization according to the complexity of the source. Because these decisions differ between codecs, encoders, and presets, results at the same nominal bitrate can look or sound different, so judge settings on your own content. Pipelines normally keep the highest-quality source available and create each delivery derivative from it, not from another derivative.

<span aria-hidden="true" id="key-facts"></span>

## Key facts

1. Decoding and re-encoding with a lossy encoder quantizes the data again and generally adds loss; reusing the earlier quality setting cannot bring back what was already discarded. Some operations avoid this by working on the coded data instead: libjpeg-turbo’s `jpegtran`, for example, rotates or flips a JPEG by rearranging its coefficients without fully decoding the image, so the image data is transformed without degradation, which its manual contrasts with decoding and re-encoding. The manual also states the limits: `jpegtran` cannot change image quality, rotations and flips leave partial edge blocks untransformed when the dimension the transform depends on—the width for `-flip horizontal` or `-rotate 270`, the height for `-flip vertical` or `-rotate 90`, either one for `-rotate 180`—is not a multiple of the iMCU block size (usually 8 or 16 pixels), and dropping those blocks with `-trim` is not strictly lossless.
2. Quality numbers are encoder-specific and not interchangeable. `cjpeg -quality` runs from 0 (worst) to 100 (best) and scales quantization tables, while the x265 `--crf` rate factor runs the other way: a higher value means more quantization and lower quality, and file size then depends on the complexity of the source. Compare encoders by inspecting or measuring their output, not by matching numbers.
3. The top of a quality scale is not necessarily lossless. For `cjpeg`, quality 100 only minimizes loss in the quantization step; subsampling and round-off error still lose information. Exact reconstruction needs a lossless mode or format, and because some formats, such as WebP, offer both, a file extension does not tell you which was used.
4. Changing the container does not have to cost quality. FFmpeg’s stream copy (`-c copy`) passes packets through without decoding or encoding, so there is no quality loss, but it can fail when the target container needs information the source lacks, and it cannot apply filters. Resizing is a filter, so a new video size means transcoding: decoding and encoding again, which FFmpeg’s documentation says degrades quality in most cases.

<span aria-hidden="true" id="when-it-matters"></span>

## When Lossy Compression matters

Use lossy coding when bandwidth or storage savings justify some loss of image, audio, or video fidelity. Excessive settings or repeated recompression can create visible or audible artifacts.

<span aria-hidden="true" id="transloadit"></span>

## How Transloadit helps with Lossy Compression

Transloadit exposes the lossy or lossless choice in its image Robots. `/image/optimize` uses only lossless PNG optimizers by default; setting `lossy: true` lets the lossy compressor pngquant compete as well, and the smallest result wins. `/image/resize` has a `quality` parameter that controls the compression of JPG and PNG output.

The `lossy` parameter affects PNG optimization only. The documentation warns that pngquant reduces PNGs to a 256-color palette, which may cause noticeable color shifts in images with rich color palettes, subtle gradients, or brand-specific colors.

* [Image optimization Robot: the lossy parameter→](/docs/robots/image-optimize.md)
* [Image resize Robot: the quality parameter→](/docs/robots/image-resize.md)

[Explore Transloadit’s file formats & compression capabilities](/docs/supported-formats.md)

<span aria-hidden="true" id="references"></span>

## Sources

* [MDN Glossary: Lossy compression](https://developer.mozilla.org/en-US/docs/Glossary/Lossy%5Fcompression)
* [ITU-T T.81 | ISO/IEC 10918-1: JPEG requirements and guidelines (DCT quantization, Annex K)](https://www.w3.org/Graphics/JPEG/itu-t81.pdf)
* [libjpeg-turbo: cjpeg and djpeg usage (the -quality switch)](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/doc/usage.txt)
* [libjpeg-turbo: jpegtran manual (lossless JPEG transformations)](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/doc/jpegtran.1)
* [x265 documentation: command line options (CRF and adaptive quantization)](https://x265.readthedocs.io/en/master/cli.html)
* [FFmpeg documentation: ffmpeg tool (Streamcopy and Transcoding)](https://ffmpeg.org/ffmpeg.html)

[← Lossless Compression](/glossary/lossless-compression.md)[Low-Latency DASH →](/glossary/low-latency-dash.md)

More in file formats & compression

* [JPF File](/glossary/jpf-file.md)
* [JPM File](/glossary/jpm-file.md)
* [JPX File](/glossary/jpx-file.md)
* [M2TS File](/glossary/m2ts-file.md)
* [M2V File](/glossary/m2v-file.md)
* [M3U8](/glossary/m3u8.md)

[All 505 terms](/glossary.md)

## Turn media knowledge into a working pipeline

Connect uploads, processing, AI, storage, and delivery through one declarative API — with the encoding stack, scaling, and format churn handled for you.

[Try Transloadit for free](/c/signup/)
