{
  "id": "jpeg",
  "title": "JPEG",
  "lang": "en",
  "source_lang": "en",
  "summary": "JPEG is a family of still-image coding standards best known for widely used lossy compression based on quantized discrete cosine transforms.",
  "category": "computer-science",
  "subcategory": "software",
  "type": "concept",
  "aliases": [
    "Joint Photographic Experts Group image coding standard",
    "JPEG image compression",
    "JPG"
  ],
  "generated_at": "2026-11-02",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/jpeg/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/jpeg/",
      "json": "https://aiwiki.page/zh/jpeg.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "JPEG is a standard for compressing continuous-tone still images, especially photographs and scanned pictures. The name comes from the Joint Photographic Experts Group, the committee responsible for developing the standard. In everyday usage, “JPEG” usually means the widely implemented, lossy, block-transform coding process standardized as ITU-T Recommendation T.81 and ISO/IEC 10918-1, together with familiar image files bearing the extensions .jpg or .jpeg. More precisely, the standard defines several coding processes, including a separate lossless process, while common file conventions specify additional rules for exchanging encoded images.\n\nJPEG became a central technology of digital photography, the World Wide Web, and electronic image distribution because it can reduce photographic data substantially while retaining an acceptable visual appearance. Its most familiar process combines color-component subsampling, an 8-by-8 discrete cosine transform, quantization, and entropy coding. These operations exploit both statistical redundancy and the unequal visual importance of different image details.\n\nUnderstanding JPEG requires distinguishing the coding standard from file formats, encoder settings, and later standards developed by the same committee. The original JPEG does not prescribe a universal “quality” scale, require one particular color space, or guarantee identical reconstructed pixels across all conforming implementations. Its enduring interoperability instead rests on a comparatively stable compressed-data syntax and an extensive ecosystem of encoders, decoders, cameras, browsers, and editing applications."
    },
    {
      "heading": "Origins, standardization, and scope",
      "text": "JPEG emerged from efforts during the 1980s to establish an international standard for compressing continuous-tone images. The Joint Photographic Experts Group was established in 1986 through collaboration between the international standards communities then associated with ISO and CCITT, the predecessor organization of the ITU Telecommunication Standardization Sector. The work addressed photographs and other images with smoothly varying tones, rather than principally text documents or simple line drawings.\n\nThe development process compared competing coding approaches and selected a block-based transform method as the foundation of the widely used lossy processes. The discrete cosine transform, introduced in a landmark 1974 paper by Nasir Ahmed, T. Natarajan, and K. R. Rao, provided an efficient way to represent spatial image information as frequency coefficients. Natural images often concentrate much of their signal energy in relatively low spatial frequencies, making this representation well suited to selective reduction of precision. The committee combined it with quantization and statistical coding rather than treating the transform alone as compression.\n\nITU-T Recommendation T.81 was approved in 1992, and the corresponding ISO/IEC 10918-1 standard was published in 1994. Their title, Digital compression and coding of continuous-tone still images: Requirements and guidelines, reflects a broader scope than the familiar baseline JPEG file. The specification includes sequential and progressive transform coding, both Huffman and arithmetic entropy coding, a predictive lossless process, and a hierarchical mode. Later parts of the 10918 series address matters such as compliance testing, extensions, and interchange conventions.\n\nA crucial distinction is between the standard’s complete repertoire and its baseline process. Baseline sequential DCT coding uses 8-bit samples and Huffman coding. It became the common denominator for image interchange because its requirements were manageable for software and hardware of the period. A decoder described merely as supporting “JPEG” may implement this widely used subset without supporting every process in T.81.\n\nThe committee’s name subsequently became an umbrella for additional image-coding standards, but those standards are not simply new settings for the original JPEG bitstream. JPEG 2000, JPEG-LS, and JPEG XL have different coding structures and compatibility properties. Likewise, a file extension identifies a convention rather than proving that a file contains a particular coding process. The original standard’s influence therefore concerns both a specific technical design and an unusually durable interoperability baseline within the broader history of data compression."
    },
    {
      "heading": "Image components, color conversion, and subsampling",
      "text": "JPEG operates on image components represented as arrays of samples. These components may describe grayscale, red–green–blue values, luminance-like and color-difference signals, or other arrangements. The core coding syntax does not, by itself, assign a universal color meaning to every component. That interpretation depends on the surrounding interchange convention and metadata. Consequently, saying that JPEG “uses YCbCr” describes common practice, not an unconditional requirement of the coding standard.\n\nMost photographic JPEG files convert RGB data to YCbCr. Here \\(Y\\) is a luma signal calculated from nonlinear RGB components, while \\(Cb\\) and \\(Cr\\) represent blue-difference and red-difference chroma information. A frequently used full-range conversion for 8-bit inputs is approximately\n\n\\[Y=0.299R+0.587G+0.114B,\\]\n\n\\[Cb=128-0.168736R-0.331264G+0.5B,\\]\n\n\\[Cr=128+0.5R-0.418688G-0.081312B.\\]\n\nThese equations belong to common color-encoding conventions; they are not the mathematical definition of JPEG compression. Different color interpretations or range assumptions can produce visibly different results even when the compressed coefficients are decoded correctly.\n\nSeparating luma and chroma enables chroma subsampling, which reduces the spatial resolution of color-difference components. Human vision generally resolves fine brightness variations more readily than fine chromatic variations, particularly under ordinary photographic viewing conditions. In a typical 4:2:0 arrangement, each chroma component has half the luma width and half its height, giving one sample in each chroma plane for every four luma samples. A 4:2:2 arrangement halves chroma resolution horizontally but not vertically; 4:4:4 preserves equal component resolution. Subsampling is distinct from transform quantization and can introduce irreversible loss before the transform begins.\n\nJPEG describes these relationships using horizontal and vertical sampling factors. In an interleaved three-component 4:2:0 scan, a common minimum coded unit contains four 8-by-8 luma blocks and one block from each chroma component. It therefore covers a 16-by-16 region at luma resolution. With 4:4:4 sampling, an interleaved minimum coded unit commonly contains one block from each component and covers an 8-by-8 region. These groupings govern scan organization and affect restart intervals and lossless block-domain editing.\n\nSubsampling requires filtering to avoid aliasing, while decoding requires chroma upsampling to reconstruct a full-resolution display image. The filters and sample-position assumptions influence sharpness and colored-edge behavior. Small colored text, diagrams, and saturated boundaries can therefore deteriorate even when transform quantization is mild. Grayscale images avoid chroma coding altogether, while four-component print workflows may use CMYK or YCCK conventions whose interpretation requires particular care. Color conversion, sampling, and display management are separate stages, each capable of changing the final appearance."
    },
    {
      "heading": "Block transforms and quantization",
      "text": "The familiar lossy JPEG process divides each component into 8-by-8 blocks. For baseline 8-bit samples, values are shifted downward by 128 so that the nominal range becomes \\(-128\\) to \\(127\\). The encoder then transforms each block from spatial samples into 64 frequency coefficients. This blockwise structure makes computation and memory requirements manageable, but it also establishes the spatial grid associated with characteristic JPEG blocking artifacts.\n\nFor a level-shifted block \\(f(x,y)\\), the two-dimensional transform can be written as\n\n\\[F(u,v)=\\frac{1}{4}C(u)C(v) \\sum_{x=0}^{7}\\sum_{y=0}^{7}f(x,y) \\cos\\left(\\frac{(2x+1)u\\pi}{16}\\right) \\cos\\left(\\frac{(2y+1)v\\pi}{16}\\right),\\]\n\nwhere \\(C(0)=1/\\sqrt{2}\\), \\(C(k)=1\\) for \\(k>0\\), and \\(u,v\\) range from 0 to 7. The coefficient \\(F(0,0)\\), called DC, represents the block’s average level up to the transform’s scaling. The remaining 63 AC coefficients describe progressively varying horizontal and vertical patterns. The transform redistributes information; in exact arithmetic, it is reversible and does not itself discard image content.\n\nLoss primarily enters through quantization. Each coefficient is divided by a corresponding positive entry in a quantization table and rounded to an integer:\n\n\\[q(u,v)=\\operatorname{round}\\left(\\frac{F(u,v)}{Q(u,v)}\\right).\\]\n\nA larger table entry produces coarser precision. Encoders commonly use finer steps for low-frequency coefficients and coarser steps for high-frequency coefficients, reflecting both typical image statistics and visual sensitivity. Separate tables often serve luma and chroma. The standard includes example tables, but ordinary JPEG files are not required to use one universal pair.\n\nQuantization creates compression opportunities because many small coefficients become zero, while the remaining integers require fewer bits than the original high-precision values. A smoothly shaded block may be represented chiefly by its DC value and a few low-frequency terms. A textured or noisy block generally retains more nonzero coefficients at comparable quantization settings. Thus two images with identical dimensions and the same encoder “quality” setting can have substantially different file sizes.\n\nDuring decoding, each quantized coefficient is multiplied by its table entry, and an inverse transform reconstructs approximate samples. Level shifting, rounding, and range limiting then produce output component values. The original position within each quantization interval cannot ordinarily be recovered. Different conforming inverse-transform implementations may also differ slightly because of finite-precision arithmetic. The distinction matters for pixel-exact comparisons: a valid JPEG bitstream does not necessarily imply one uniquely mandated integer output for every implementation. The standard constrains reconstruction accuracy without requiring all decoders to share the same internal arithmetic."
    },
    {
      "heading": "Coefficient ordering and entropy coding",
      "text": "After quantization, JPEG encodes coefficient values without introducing another intentional loss of image information. This stage uses statistical structure rather than visual approximation: repeated zeros, small magnitudes, and correlations between neighboring blocks are represented compactly. It is therefore useful to distinguish the lossy quantization stage from the subsequent lossless compression of the quantized representation.\n\nFor sequential DCT coding, the DC coefficient is treated separately from the AC coefficients. Because neighboring blocks often have similar average values, the encoder codes the difference between the current DC coefficient and a predictor associated with that component, rather than coding the absolute value each time. A size category describes how many additional bits are needed to represent the difference. The entropy-coded category and the following value bits together identify the signed difference. Prediction state is reset at defined boundaries, including restart markers.\n\nThe 63 AC coefficients are visited in a zigzag order that moves approximately from low toward high spatial frequencies. This does not change their values; it tends to bring long runs of zero coefficients together near the end of the sequence. Baseline Huffman coding combines the number of preceding zeros with the size category of the next nonzero coefficient. Four bits are available for each part of this run/size symbol. Special symbols represent the end of a block’s nonzero coefficients and a run of 16 zeros, allowing longer zero stretches to be expressed through repeated run symbols.\n\nHuffman tables assign shorter codewords to more frequent symbols. Encoders may use familiar general-purpose tables or construct tables adapted to the image’s actual symbol frequencies. Image-specific optimization can reduce file size without changing quantization or reconstructed image content, although it requires additional statistics collection and may add overhead for small images. The compressed stream carries table definitions when they are needed for interchange, so decoders do not have to infer the encoder’s statistical choices.\n\nThe original JPEG standard also specifies arithmetic coding, which represents a sequence through successive probability-based interval refinement rather than assigning a separate Huffman codeword to every symbol. Historical patent concerns and limited software support contributed to its much narrower deployment. Arithmetic coding is distinct from progressive presentation: progressive JPEG can use Huffman coding, and arithmetic coding does not inherently imply progressive delivery.\n\nJPEG’s byte syntax also protects the distinction between entropy-coded data and structural markers. A data byte with hexadecimal value FF is followed by a stuffed zero byte so that it is not mistaken for a marker. Optional restart markers divide entropy-coded segments and reset relevant coding state. They limit some forms of error propagation and can facilitate segmented decoding, but they are not an error-correcting code and cannot reconstruct missing information."
    },
    {
      "heading": "Sequential, progressive, lossless, and hierarchical processes",
      "text": "JPEG’s coding processes differ in how image information is represented and delivered. The most familiar process is baseline sequential DCT coding: each block’s quantized coefficients are transmitted in a sequential scan, using 8-bit sample precision and Huffman entropy coding. A scan may interleave several components, or components may be carried in separate scans. “Sequential” therefore does not necessarily mean that an entire file contains exactly one scan.\n\nProgressive DCT coding distributes coefficients across multiple scans so that an incomplete file can yield an approximate image before all detail has arrived. Spectral selection sends chosen frequency bands in different scans—for example, DC information before higher-frequency AC coefficients. Successive approximation sends more significant coefficient bits first and refines them later. The two techniques can be combined within the rules of the standard. Unlike a thumbnail stored beside the main image, progressive display is reconstructed from successive portions of the main coded representation.\n\nFor the same final quantized coefficient values, progressive and sequential representations can reconstruct the same image, apart from implementation-level numerical differences. Progressive encoding therefore does not inherently improve the final image’s fidelity. It can improve perceived loading behavior and sometimes coding efficiency, but the result depends on scan design and content. Decoders generally need to retain coefficient information for later refinement, creating different memory and processing requirements from a simple streaming baseline implementation. Intermediate renderings also depend on how and when the application chooses to update its display.\n\nThe original standard’s lossless process uses prediction rather than DCT quantization. It predicts a sample from already decoded neighbors and entropy-codes the prediction error. Available predictors include the left sample, the sample above, the upper-left sample, and combinations of these values. With the point transform set to zero, this process preserves the input sample values exactly. A nonzero point transform discards low-order sample bits before coding and therefore changes what can be recovered. The original predictive lossless process supports sample precisions from 2 to 16 bits, but it is not widely supported by ordinary photographic JPEG software.\n\nHierarchical coding represents an image through multiple resolutions, using lower-resolution information to assist reconstruction at higher resolutions. It belongs to the original standard but did not become a normal feature of consumer .jpg interchange. Extended DCT processes likewise support capabilities beyond baseline, including 12-bit sample precision.\n\nThese distinctions explain why “JPEG support” is not a complete capability statement. Baseline, progressive, 12-bit, arithmetic-coded, and original lossless streams may require different decoder support. JPEG-LS is especially easy to confuse with the original lossless mode: it is a separate standard, published in the ISO/IEC 14495 series, with a different predictive coding design and its own bitstream syntax."
    },
    {
      "heading": "File organization, interchange conventions, and metadata",
      "text": "The JPEG coding standard defines a structured stream, but widely exchanged files also depend on conventions that specify color interpretation, metadata, and packaging. Two particularly important conventions are the JPEG File Interchange Format (JFIF) and Exchangeable image file format (Exif). A file can contain JPEG-compressed image data together with application-specific segments, so “JPEG file format” often refers to an ecosystem of compatible conventions rather than one completely self-contained definition in T.81.\n\nA typical stream begins with a start-of-image marker and ends with an end-of-image marker. Between them, markers introduce quantization tables, Huffman tables, frame information, scan headers, and optional application data. A start-of-frame segment identifies the coding process, image dimensions, component identifiers, sampling factors, and quantization-table assignments. A start-of-scan segment identifies the components and coding parameters used in the following entropy-coded data. Progressive images repeat scan headers and coded scans as their coefficient representation is refined.\n\nMost marker segments carry a two-byte length field; the length includes those two bytes but excludes the marker itself. The resulting maximum payload for one such segment is 65,533 bytes. Large metadata objects must therefore be divided across multiple segments according to the relevant convention. Not every marker has a length field: start-of-image, end-of-image, and restart markers are among the exceptions. Frame dimensions use 16-bit fields, imposing limits distinct from whatever smaller limits an application chooses for safety or memory management.\n\nJFIF conventionally places an identifying record in an APP0 segment and establishes common interpretations for grayscale and YCbCr images. Exif commonly uses APP1 and stores structured metadata using TIFF-style directories. In files produced by a digital camera or smartphone, this metadata may include exposure time, aperture, focal length, capture time, orientation, and location coordinates when recorded. Orientation is particularly consequential: an image’s stored pixel arrangement may differ from the intended display orientation, and applications that ignore the orientation field can display it rotated or mirrored.\n\nOther application segments support additional information. ICC color profiles are conventionally carried in APP2 segments, potentially split across several records. Adobe APP14 information helps identify certain RGB, CMYK, and YCCK interpretations. XMP metadata commonly occupies APP1 under a separate identifying convention. These records serve different purposes and are not interchangeable.\n\nMetadata can be edited or removed without recompressing the image coefficients. Nevertheless, removing it may alter appearance if an essential color profile or orientation instruction is lost. Metadata can also reveal information relevant to data privacy, such as capture location. The original widely used JPEG interchange conventions do not provide a standard alpha channel; transparency generally requires a different image format or an application-specific arrangement."
    },
    {
      "heading": "Image quality, artifacts, and editing behavior",
      "text": "JPEG’s compression ratio is not a fixed property of the format. It depends on image dimensions, content, component sampling, quantization tables, coding mode, entropy tables, and metadata overhead. A smooth studio background compresses more readily than foliage, film grain, or sensor noise because irregular fine detail produces more significant transform coefficients. Photographic compression ratios around 10:1 can often retain good visual quality, but no ratio guarantees the same quality across images or viewing conditions.\n\nThe “quality” value exposed by software is an encoder control, not a standardized quantity stored in every JPEG file. Different programs map values such as 75 or 90 to different quantization tables, sampling choices, and optimization policies. Even within one implementation, a quality setting need not describe every source of loss. A setting of 100 does not generally mean mathematically lossless coding: color conversion, chroma subsampling, coefficient rounding, and transform implementation can still alter samples. File-size comparisons based only on equal quality numbers are consequently unreliable across encoders.\n\nCharacteristic artifacts arise from different parts of the pipeline. Blocking appears when neighboring 8-by-8 blocks reconstruct with visibly mismatched boundaries. Ringing produces oscillatory patterns near sharp transitions because a truncated or coarsely quantized frequency representation cannot reproduce the edge exactly. Fine textures may become smooth or patchy as high-frequency coefficients disappear. Chroma subsampling can blur or displace colored edges independently of luma sharpness. Text and line art are particularly revealing because their high-contrast boundaries and flat regions make these distortions conspicuous.\n\nRepeated decompression and recompression can introduce generation loss. A newly encoded image is based on an already approximated reconstruction, and further quantization may discard additional information. The amount of damage depends on whether block alignment, quantization tables, color conversion, and sampling remain consistent. Recompression is not guaranteed to cause the same amount of deterioration at every generation; some combinations stabilize more readily than others. A crop or rotation that shifts the block grid can make subsequent changes particularly substantial.\n\nCertain operations can instead be performed directly on quantized DCT coefficients. Under suitable alignment conditions, 90-degree rotations, reflections, and crops can avoid another quantization pass. Such “lossless JPEG transformations” preserve the coded image information relevant to the operation, but partial edge blocks and minimum-coded-unit boundaries complicate what can be preserved exactly. A tool may trim edges, restrict the transform, or handle boundaries differently. Coefficient-domain losslessness also does not necessarily imply bit-for-bit identical pixel output across all decoders.\n\nObjective measures such as peak signal-to-noise ratio quantify reconstruction error, while structural similarity attempts to model aspects of perceived structure. Neither fully predicts human judgments for every image. Viewing distance, display resolution, subject matter, color fidelity, and the intended use all influence which distortions matter most."
    },
    {
      "heading": "Implementations, applications, and related standards",
      "text": "JPEG’s practical success depends on implementations as much as on its mathematical design. The Independent JPEG Group’s software, first released in 1991, provided a widely reused implementation and helped establish common encoder and decoder behavior. Later projects such as libjpeg-turbo accelerated compatible operations through processor-specific vector instructions. Optimized transforms, color conversion, and entropy handling made JPEG inexpensive to process on personal computers, servers, and mobile devices. Dedicated hardware also made it practical for cameras and other constrained systems.\n\nA decoder’s work includes more than applying an inverse transform. It must parse variable-length structures, validate dimensions and tables, manage component sampling, decode entropy-coded symbols, reconstruct samples, interpret relevant metadata, and convert output for display. Malformed inputs can expose buffer overflows, integer-overflow errors, or excessive resource consumption in defective implementations. Even a compressed file with a modest byte size can describe an image requiring considerable decoded memory. JPEG decoding is consequently both a multimedia function and a security-sensitive parser operation.\n\nJPEG is especially well matched to photographs where moderate approximation is acceptable and broad compatibility is valuable. It is used in web browsers, photographic archives, messaging systems, publishing workflows, and camera output. The media type image/jpeg identifies it in Internet protocols. Its widespread support makes it a durable delivery format, although its ordinary lossy process does not preserve an original sensor capture or an exact scientific measurement. Applications that need those properties use different storage representations or specifically lossless coding processes.\n\nRelated formats address limitations or different priorities. PNG uses lossless coding and supports transparency, making it useful for interface graphics, diagrams, and exact pixel preservation. JPEG 2000, first standardized in 2000, uses wavelet-based coding and supports features such as resolution scalability and both lossy and lossless reconstruction. JPEG-LS targets efficient lossless and near-lossless coding of continuous-tone images. None is decoded merely by a baseline JPEG decoder.\n\nWebP and AVIF provide other combinations of photographic compression, lossless modes, transparency, and animation. Their size advantages vary with content, encoder effort, and target quality rather than following one universal percentage. JPEG XL combines modern image-coding features with a provision for reversibly transcoding supported legacy JPEG bitstreams, allowing the original JPEG representation to be reconstructed exactly. That capability is different from decoding an image and making a visually similar new JPEG.\n\nSome extensions retain a conventional JPEG image as a compatibility layer while adding information for more capable software. Gain-map approaches, for example, associate a base image with auxiliary data for high-dynamic-range rendering. Applications that understand only the base JPEG may still display the ordinary image, while compatible implementations use the additional representation. The appearance then depends not only on baseline JPEG decoding but also on the extension’s metadata, rendering rules, and display capabilities."
    }
  ],
  "links": [
    "world-wide-web",
    "discrete-cosine-transform",
    "huffman-coding",
    "data-compression",
    "aliasing",
    "quantization-signal-processing",
    "lossless-data-compression",
    "arithmetic-coding",
    "error-correcting-code",
    "camera",
    "smartphone",
    "data-privacy",
    "personal-computer",
    "web-browser",
    "png"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}