JPEG

From Just Solve the File Format Problem
Revision as of 18:30, 15 February 2013 by Jsummers (Talk | contribs)

Jump to: navigation, search
File Format
Name JPEG
Ontology
Extension(s) .jpg
.jpeg
.jpe
.jif
.jfif
.jfi
MIME Type(s) image/jpeg

JPEG, named after the Joint Photographic Experts Group, which created the format, is a lossy compressed format well-suited to photographic images. Line drawings do better with non-lossy compressed bitmaps such as GIF and PNG.

Depending on context, "JPEG" may mean the compression algorithm, or the JPEG interchange format (JIF) defined in the JPEG standard.

In and of itself, JPEG is not really a suitable format for image interchange, for several reasons:

  • It essentially only defines a way to store one or more arrays of numbers. It does not say how to interpret those numbers as an image. The decoder will just have to guess.
  • It is large and general, and it would be unrealistic to expect every decoder to support all of it.
  • It has no standard way to store metadata.

To address these issues, a number of JPEG subformats have been invented. JFIF is by far the most popular of them, though a significant minority of JPEG files use Exif/JPEG instead. The SPIFF file format was intended as a replacement for JFIF but never caught on widely.

Contents

Format

A JPEG file consists largely of a sequence of tagged segments. Each segment begins with a two-byte "marker". The first byte of a marker is 0xff. The second may have any value except 0x00 or 0xff, and indicates the type of data stored in the segment. Segment types are assigned names; for example, 0xd9 is "SOI", and 0xe1 is "APP1".

Segment types 0x01, and 0xd0 through 0xd9, consist entirely of the two-byte marker. All other markers are followed by a two-byte integer indicating the size of the segment, followed by the payload data contained in the segment.

The image data is the exception to this segmented format. It appears between the 0xda ("SOS") and 0xd9 ("EOI") segments, but there is no prefix to indicate its size. Instead, any 0xff bytes in the image data are escaped as 0xff 0x00, so that they won't be mistaken for markers.

Application segments

There are 16 segment types reserved for application-specific data: 0xe0 ("APP0") through 0xef ("APP15").

An APP segment's data usually begins with NUL-terminated string to identify the type of data contained in it. The actual payload data then begins after the NUL byte. This is a convention, not a part of the JPEG specification.

Related Formats

ICC profile data is contained in an APP2 "ICC_PROFILE" segment.

The Exif standard uses an APP1 "Exif" segment.

FlashPix data is contained in APP2 "FPXR" segments in Exif-compliant JPEGs. Refer to the Exif specification.

Photoshop Image Resources is contained in an APP13 "Photoshop 3.0" segment.

IPTC metadata often appears in JPEG files, embedded in Photoshop Image Resources.

XMP metadata is contained in an APP1 "http://ns.adobe.com/xap/1.0/" segment.

Many other file formats, such as TIFF, MNG, and DICOM, can contain JPEG-compressed data or encapsulated JPEG files.

Specifications

References

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox