JPEG is a lossy image compression standard and the file format built on it, named after the Joint Photographic Experts Group that defined it in the early 1990s. In photography and image processing, JPEG is the format in which cameras, phones and editing software deliver a finished, rendered photograph: demosaiced, white balanced, tone mapped, sharpened and reduced to 8 bits per channel.
Its success rests on a simple trade-off: JPEG discards detail that the human eye notices least, so a typical photograph shrinks to roughly one-tenth of its uncompressed size with little visible change. The cost is that the file is no longer suitable for heavy editing, unlike a RAW file that keeps the original sensor data.
How JPEG compression works
Baseline JPEG compression runs as a fixed sequence of steps, and only one of them actually throws information away. First the image is converted from RGB to YCbCr color space, which separates brightness (luma) from color (chroma). Because human vision resolves brightness detail better than color detail, the chroma channels are usually stored at reduced resolution, a step called chroma subsampling.
The image is then divided into 8×8 pixel blocks, and each block is transformed with the discrete cosine transform (DCT) into 64 frequency coefficients. A quantization table divides these coefficients and rounds the results, which reduces fine high-frequency detail to zero. Finally, lossless Huffman entropy coding packs the remaining values efficiently.
The table below lists each stage and whether it loses data.
| Stage | Purpose | Data loss |
|---|---|---|
| Color conversion | Separates luma from chroma | Minimal rounding only |
| Chroma subsampling | Reduces color resolution | Yes, color detail |
| Discrete cosine transform | Expresses blocks as frequencies | No |
| Quantization | Rounds frequency coefficients | Yes, the main loss |
| Entropy coding | Packs data with Huffman codes | No |
Quality settings and chroma subsampling
The quality setting in an encoder does not appear in the file itself; it simply scales the quantization tables. Higher values use smaller divisors, keep more coefficients and produce larger files. The relationship is strongly nonlinear: the step from quality 90 to 100 can nearly double file size while adding detail few viewers can see.
| Quality range | Relative file size | Typical use |
|---|---|---|
| 95-100 | Very large | Archival masters, print handoff |
| 85-92 | Large | Camera fine mode, client delivery |
| 70-84 | Medium | Web galleries and portfolios |
| 50-69 | Small | Thumbnails and previews |
| Below 50 | Very small | Only where bandwidth is critical |
Subsampling is written as a ratio. 4:4:4 keeps full color resolution, 4:2:2 halves it horizontally, and 4:2:0 halves it in both directions, which is the default in most cameras and web encoders. Subsampling is harmless for most photographs but can blur saturated red edges and fine colored text.
JPEG compared with RAW and modern formats
JPEG competes with formats that keep more data or compress more efficiently, and the right choice depends on where the file sits in the workflow. RAW belongs at capture and editing; JPEG and its successors belong at delivery.
| Format | Compression | Bit depth | Main strength |
|---|---|---|---|
| JPEG | Lossy | 8-bit | Universal compatibility |
| RAW | Lossless or lightly lossy | 12-14 bit | Maximum editing latitude |
| PNG | Lossless | 8 or 16 bit | Graphics and transparency |
| HEIC | Lossy, HEVC based | 8-10 bit | Smaller files on phones |
| WebP | Lossy or lossless | 8-bit | Efficient web delivery |
| AVIF | Lossy, AV1 based | 8-12 bit | High efficiency and HDR |
Newer formats such as AVIF and HEIC typically reach similar visual quality at 30-50 percent smaller sizes, and they support wider bit depths. JPEG remains dominant because every browser, operating system, printer and photo lab reads it without conversion. Extensions such as JPEG XL promise lossless recompression of existing JPEG files, but support is still uneven.
Metadata, color and file structure
A JPEG file is a sequence of marker segments that hold the compressed image together with descriptive data. The EXIF segment records camera settings, date, orientation and often GPS coordinates; an embedded ICC color profile such as sRGB or Adobe RGB tells software how to interpret the color values.
A missing or ignored profile is a common cause of dull or oversaturated colors when an Adobe RGB file is displayed as if it were sRGB. For web delivery, converting to sRGB before export is the safe default. Removing location data before publishing is also a basic privacy precaution.
Two encoding modes affect how a file loads. Baseline JPEG draws the image from top to bottom as data arrives, while progressive JPEG sends a coarse version of the whole frame first and refines it in later passes. Progressive files are often slightly smaller and feel faster on slow connections, so many web optimization tools choose them by default.
Artifacts, generation loss and common mistakes
Strong quantization produces characteristic compression artifacts. Visible block edges, ringing around sharp contrast and stepped gradients all come from the 8×8 structure and the rounding of coefficients.
| Artifact | Cause | Prevention |
|---|---|---|
| Blocking | Coarse quantization of 8×8 blocks | Raise the quality setting |
| Ringing | Lost high frequencies near edges | Avoid heavy sharpening before export |
| Banding | 8-bit depth and smoothing of gradients | Add slight grain, edit in 16-bit |
| Color bleeding | Chroma subsampling | Export with 4:4:4 when color edges matter |
| Generation loss | Repeated decode and re-encode | Edit the master, export once |
- Do not use JPEG as an editing master; save layered or 16-bit working files instead.
- Avoid opening, editing and saving the same JPEG repeatedly, because each save quantizes again.
- Lossless operations such as 90-degree rotation can be done without recompression in suitable tools.
- Shooting RAW plus JPEG gives an immediate shareable file and a full-quality original.
A plain-language summary
JPEG is the most common way to save and share photos. It makes pictures much smaller by quietly leaving out tiny details and color nuances that people rarely notice, a bit like summarizing a long letter while keeping its meaning.
The summary works well for viewing, but each new save loses a little more. For that reason photographers keep an original and use JPEG as the final copy to share.
An example from practice
A real estate photographer shoots a house interior in RAW, edits the 40 selected frames in 16-bit, and must deliver them to an agency whose listing platform accepts files up to 2 MB. Exporting at full resolution with quality 100 produces files of about 12 MB, far above the limit.
The photographer resizes the images to 3000 pixels on the long edge, converts them to sRGB, removes GPS data from the EXIF block and exports at quality 82 with 4:2:0 subsampling. Each file lands between 1.1 and 1.6 MB, loads quickly on the listing site, and shows no visible blocking even on smooth white ceilings, while the RAW originals stay archived for any later print request.