What is JPEG?
JPEG is a widely supported method of lossy compression for raster photographs and other continuous-tone imagery. Compression quality is adjustable, but common JPEG encoding does not provide transparency.
How JPEG works
The common JPEG process splits each color component into 8×8 blocks, transforms each block with a discrete cosine transform, divides the resulting coefficients by values from a quantization table, rounds the results to integers, and entropy-codes them. Quantization is the step that discards detail: coarser tables shrink the file at the cost of visible errors, most noticeably blurring and color fringes around text and sharp edges. Encoders commonly also store the two chroma components at reduced resolution, which is a second, separate source of loss. The JPEG standard defines the compressed data and its marker syntax but leaves color space and other application information out of scope, which is why files commonly follow a convention such as JFIF or Exif and may carry an ICC profile and descriptive metadata in application segments.
Key facts
- A quality number is an encoder convention, not part of the JPEG standard: the standard specifies no default quantization tables, and libjpeg-style encoders map a 0–100 value onto scaled tables, so the same number need not give the same result in another encoder. Quality 100 is not lossless. In libjpeg-turbo it minimizes quantization loss, but chroma subsampling and rounding still discard information, and files grow sharply above about 95 for little visible gain.
- Baseline JPEG is the 8-bit, sequential, Huffman-coded process that every DCT-based decoder must support, and it codes each component in a single scan. Progressive JPEG stores the same quantized coefficients across multiple scans, so a decoder can show a coarse full image early and refine it. The final image is identical to the sequential one at the same settings and the file is about the same size, but decoding requires a coefficient buffer for the whole image.
- Every decode-and-re-encode cycle quantizes again, so loss accumulates across saves; when the pixels must change, re-encode from the original rather than from an earlier output. Tools that work on the stored coefficients avoid the cycle:
jpegtrancan switch between baseline and progressive, flip an image, or rotate it in 90° steps without degrading it. Two limits apply. Such tools cannot change quality, and a flip or rotation can leave an edge strip untransformed, or trim it off if asked, when the relevant width or height is not a multiple of the iMCU (interleaved minimum coded unit) size; which dimension matters depends on the transform. That unit depends on the chroma subsampling in use and is usually 8 or 16 pixels, so dimensions divisible by 8 are not always enough. Metadata is a separate matter: by defaultjpegtrancopies comments and drops other metadata, such as Exif data and an ICC profile, unless told to keep it. Comment text sits in its own marker segment and does not interfere with the image data, so adding or replacing it needs no re-encode either. - The JPEG standard also defines a lossless mode, but it is a separate, non-DCT process that many decoders cannot read. When exact pixels or transparency are required, use a format such as PNG instead; JPEG has no alpha channel.
When JPEG matters
Choose JPEG when broad compatibility and small photographic files matter more than exact pixel preservation. Repeated encoding or aggressive compression can introduce blocking, ringing, and lost detail.
How Transloadit helps with JPEG
Transloadit’s /image/resize Robot writes JPEG when format is set to jpg, with a quality parameter for the compression level, a progressive switch, and strip to remove metadata. JPEG output cannot keep transparency, and by default the Robot replaces the background of transparent images with its background color. The /image/optimize Robot reduces the size of existing JPEG files and can keep or drop their metadata.
- Image resize Robot: format, quality, progressive, and background
- Image optimize Robot
- Supported image formats
Explore Transloadit’s file formats & compression capabilities
Sources
- CCITT Rec. T.81 | ISO/IEC 10918-1: Digital compression and coding of continuous-tone still images
- libjpeg-turbo usage.txt: cjpeg quality, progressive, and jpegtran lossless transforms
- libjpeg-turbo: Using the IJG JPEG Library (color spaces, markers, memory usage)
- MDN: Image file type and format guide (JPEG)