Convert Progressive to Baseline JPEG Losslessly
A progressive JPEG can be converted to a baseline JPEG without re-quantizing pixels or degrading visual quality. Because the distinction between progressive and baseline JPEGs lies entirely in how the encoded data is organized rather than how it is compressed, the conversion is completely lossless. This guide explains the mechanics behind this transformation and how to perform it using standard imaging tools.
Progressive vs. Baseline JPEGs
Both baseline and progressive JPEGs use the same underlying compression algorithm: dividing the image into 8x8 blocks, applying the Discrete Cosine Transform (DCT), and quantizing the resulting frequency coefficients. Quantization is the only lossy step in JPEG compression.
The difference between the two formats is the scan order:
- Baseline JPEG: Encodes each 8x8 block completely (both low and high frequencies) sequentially from left to right, top to bottom.
- Progressive JPEG: Encodes the image in multiple passes across the entire frame. The first pass contains low-frequency data (giving a low-resolution preview), followed by subsequent passes that add higher-frequency details.
Why Re-Quantization Is Not Required
Re-quantization only happens if an image is fully decoded back to uncompressed RGB/YCbCr pixels and then compressed again.
Converting from progressive to baseline only requires decoding the entropy layer (Huffman or arithmetic coding) to access the already-quantized DCT coefficients. These coefficients are then rearranged from progressive scans into sequential baseline blocks and re-encoded using Huffman coding. Because the DCT coefficients are never dequantized or converted back to spatial pixels, no image degradation occurs.
How to Convert Losslessly
The most common tool for this operation is jpegtran, a
command-line utility provided by the Independent JPEG Group (IJG) and
included in libjpeg-turbo.
To convert a progressive JPEG to a baseline JPEG without re-quantizing, run:
jpegtran -copy all -baseline input_progressive.jpg output_baseline.jpg-baseline: Forces the output file to use standard baseline sequential encoding.-copy all: Preserves all metadata, such as EXIF, IPTC, and ICC color profiles.
The resulting file will be a strictly baseline sequential JPEG containing the exact same numerical coefficient values as the original progressive file.