JPEG File Interchange Format
The JPEG File Interchange Format (JFIF) is an image file format standard. It is a format for exchanging JPEG encoded files compliant with the JPEG Interchange Format (JIF) standard. It solves some of JIF's limitations in regard to simple JPEG encoded file interchange. As with all JIF compliant files, image data in JFIF files is compressed using the techniques in the JPEG standard, hence JFIF is sometimes referred to as "JPEG/JFIF".
Purpose
JFIF defines a number of details that are left unspecified by the JPEG Part 1 standard (ISO/IEC IS 10918-1, ITU-T Recommendation T.81[1]):
Component sample registration
JPEG allows multiple components (such as Y, Cb, and Cr) to have different resolutions, but it does not define how those differing sample arrays should be aligned. The JFIF standard requires samples to be sited "interstitially" — meaning the decoder can treat each component array as representing an array of equal-sized rectangular pixels sampled in their centers, with each array having the same exterior boundaries as the image. This is convenient for computer users, but is not the alignment used in MPEG-2 and most video applications.
Resolution and aspect ratio
The JPEG standard does not include any method of coding the resolution or aspect ratio of an image. JFIF provides resolution or aspect ratio information using an application segment extension to JPEG. It uses Application Segment #0, with a segment header of 'JFIF\x00', and specifies that this must be the first segment in the file, hence making it simple to recognise a JFIF file. Exif images recorded by digital cameras generally do not include this segment, but typically comply in all other respects with the JFIF standard.
Color space
JPEG does not define which color encoding is to be used for images. JFIF defines the color model to be used: either Y for greyscale, or YCbCr as defined by CCIR 601. Since this is not an absolute color space — unless an ICC profile, colorspace metadata, or an sRGB tag is provided and interpreted – a decoded JFIF image will be in a device-dependent RGB colorspace. Hence, JFIF does not by itself provide a mechanism for accurately transporting color-managed images across the Internet.
File format structure
A JFIF file consists of a sequence of markers or marker segments. The markers are defined in part 1 of the JPEG Standard.[1] Each marker consists of two bytes: an FF
byte followed by a byte which is not equal to 00
or FF
and specifies the type of the marker. Some markers stand alone, but most indicate the start of a marker segment that contains data bytes according to the following pattern:
FF xx s1 s2 data bytes
The bytes s1 and s2 are taken together to represent a big-endian 16-bit integer specifying the length of the following "data bytes" plus the 2 bytes used to represent the length. In other words, "s1" and "s2" specify the number of the following data bytes as 256 * s1 + s2 - 2.
According to part 1 of the JPEG standard, applications can use APP marker segments and define an application specific meaning of the data. In the JFIF standard, the following APP marker segments are defined:
- JFIF APP0 marker segment (JFIF segment for short) (mandatory)
- JFIF extension APP0 marker segment (JFXX segment for short) (optional)
They are described below.
The JFIF standard requires that the JFIF APP0 marker segment immediately follows the SOI marker. If a JFIF extension APP0 marker segment is used, it must immediately follow the JFIF APP0 marker segment.[2] So a JFIF file will have the following structure:
JFIF file structure | ||
---|---|---|
Segment | Code | Description |
SOI | FF D8 | Start of Image |
JFIF-APP0 | FF E0 s1 s2 4A 46 49 46 00 ... | see below |
JFXX-APP0 | FF E0 s1 s2 4A 46 58 58 00 ... | optional, see below |
… additional marker segments (for example SOF, DHT, COM) | ||
SOS | FF DA | Start of Scan |
compressed image data | ||
EOI | FF D9 | End of Image |
JFIF APP0 marker segment
In the mandatory JFIF APP0 marker segment the parameters of the image are specified. Optionally an uncompressed thumbnail can be embedded.
JFIF APP0 marker segment | ||
---|---|---|
Field | Size (bytes) | Description |
APP0 marker | 2 | FF E0 |
Length | 2 | Length of segment excluding APP0 marker |
Identifier | 5 | 4A 46 49 46 00 = "JFIF" in ASCII, terminated by a null byte |
JFIF version | 2 | First byte for major version, second byte for minor version (01 02 for 1.02) |
Density units | 1 | Units for the following pixel density fields
|
Xdensity | 2 | Horizontal pixel density. Must not be zero. |
Ydensity | 2 | Vertical pixel density. Must not be zero. |
Xthumbnail | 1 | Horizontal pixel count of the following embedded RGB thumbnail. May be zero. |
Ythumbnail | 1 | Vertical pixel count of the following embedded RGB thumbnail. May be zero. |
Thumbnail data | 3 × n | Uncompressed 24 bit RGB (8 bits per color channel) raster thumbnail data in the order R0, G0, B0, ... Rn, Gn, Bn; with n = Xthumbnail × Ythumbnail. |
JFIF extension APP0 marker segment
Immediately following the JFIF APP0 marker segment may be a JFIF extension APP0 marker segment. This segment may only be present for JFIF versions 1.02 and above. It allows to embed a thumbnail image in 3 different formats.
JFIF extension APP0 marker segment | ||
---|---|---|
Field | Size (bytes) | Description |
APP0 marker | 2 | FF E0 |
Length | 2 | Length of segment excluding APP0 marker |
Identifier | 5 | 4A 46 58 58 00 = "JFXX" in ASCII, terminated by a null byte |
Thumbnail format | 1 | Specifies what data format is used for the following embedded thumbnail:
|
Thumbnail data | variable | Depends on the thumbnail format. See below. |
The thumbnail data depends on the thumbnail format as follows:
Thumbnail stored using JPEG encoding | ||
---|---|---|
Field | Size (bytes) | Description |
SOI | 2 | FF D8 |
variable | Must be JIF format using YCbCr or just Y, and must not contain JFIF or JFXX segments. | |
EOI | 2 | FF D9 |
Thumbnail stored using one byte per pixel | ||
---|---|---|
Field | Size (bytes) | Description |
Xthumbnail | 1 | Horizontal pixel count of the following embedded thumbnail. Must not be zero. |
Ythumbnail | 1 | Vertical pixel count of the following embedded thumbnail. Must not be zero. |
Thumbnail palette | 768 | 256 palette entries, each containing a 24 bit RGB color value. |
Thumbnail data | n | One byte per pixel containing the index of the color within the palette,
with n = Xthumbnail × Ythumbnail. |
Thumbnail stored using three byte per pixel | ||
---|---|---|
Field | Size (bytes) | Description |
Xthumbnail | 1 | Horizontal pixel count of the following embedded thumbnail. Must not be zero. |
Ythumbnail | 1 | Vertical pixel count of the following embedded thumbnail. Must not be zero. |
Thumbnail data | 3 × n | Uncompressed 24 bit RGB (8 bits per color channel) raster thumbnail data in the order R0, G0, B0, ... Rn, Gn, Bn; with n = Xthumbnail × Ythumbnail. |
Compatibility
The newer Exchangeable image file format (Exif) is comparable to JFIF, but the two standards are mutually incompatible. This is because both standards specify that their particular application segment (APP0 for JFIF, APP1 for Exif) must immediately follow the SOI marker. In practice, many programs and digital cameras produce files with both application segments included. This will not affect the image decoding for most decoders, but poorly designed JFIF or Exif parsers may not recognise the file properly.
JFIF is compatible with Adobe Photoshop's JPEG "Information Resource Block" extensions, and IPTC Information Interchange Model metadata, since JFIF does not preclude other application segments, and the Photoshop extensions are not required to be the first in the file. However, Photoshop generally saves CMYK buffers as four-component "Adobe JPEGs" that are not conformant with JFIF. Since these files are not in a YCbCr color space, they are typically not decodable by Web browsers and other Internet software.
History
The standard was established on March 1, 1991 in a meeting at C-Cube Microsystems involving representatives of many companies, including C-Cube Microsystems, Radius, NeXT, Storm Tech, the PD JPEG group, Sun, and Handmade Software. The standard appears to have lost ownership, since C-Cube Microsystems is now defunct, and further development of the standard is dead. The latest version is v1.02, published September 1, 1992.[2]
JFIF has been standardized by ISO/IEC 10918-5:2013,[3] ITU-T T.871[4] and Ecma International TR/98.[5]
In 1996, RFC 2046 specified that the image format used for transmitting JPEG images across the internet should be JFIF. The MIME type of "image/jpeg" must be encoded as JFIF. In practice, however, virtually all Internet software can decode any baseline JIF image that uses Y or YCbCr components, whether it is JFIF compliant or not.
See also
References
- 1 2 "TERMINAL EQUIPMENT AND PROTOCOLS FOR TELEMATIC SERVICES. INFORMATION TECHNOLOGY – DIGITAL COMPRESSION AND CODING OF CONTINUOUS-TONE STILL IMAGES – REQUIREMENTS AND GUIDELINES. Recommendation T.81." (pdf, 1.1 MB). ITU-T/CCITT. 1992-02-18. Retrieved 2015-06-15.
- 1 2 Hamilton, Eric (1992-09-01). "JPEG File Interchange Format, Version 1.02." (pdf, 0.02 MB). Retrieved 2015-06-15.
- ↑ "ISO/IEC 10918-5:2013, Information technology -- Digital compression and coding of continuous-tone still images: JPEG File Interchange Format (JFIF).". ISO/IEC. 2013-05-01. Retrieved 2015-06-15.
- ↑ "TERMINALS FOR TELEMATIC SERVICES. Still-image compression – JPEG-1 extensions. Information technology – Digital compression and coding of continuous-tone still images: JPEG File Interchange Format (JFIF). Recommendation T.871." (pdf, 0.2 MB). ITU-T. 2011-05-14. Retrieved 2015-06-15.
- ↑ "JPEG File Interchange Format (JFIF)". ECMA TR/98 1st ed. Ecma International. 2009. Retrieved 2015-06-15.
Further reading
Books
- Miano, John M., "Compressed Image File Formats." 1999, Addison-Wesley. ISBN 978-0-201-60443-6.
- Pennebaker, William B. and Joan L. Mitchell: JPEG still image data compression standard. 3rd edition, 1993. Springer. ISBN 978-0-442-01272-4.
Standards
- Hamilton, Eric: JPEG File Interchange Format, Version 1.02. (PDF, 0,02 MB) 1992-09-01.
- ITU-T Recommendation T.871: TERMINALS FOR TELEMATIC SERVICES. Still-image compression – JPEG-1 extensions. Information technology – Digital compression and coding of continuous-tone still images: JPEG File Interchange Format (JFIF). 2011-05-14. (PDF, 0,2 MB)
- ITU-T Recommendation T.81: CCITT: TERMINAL EQUIPMENT AND PROTOCOLS FOR TELEMATIC SERVICES. INFORMATION TECHNOLOGY – DIGITAL COMPRESSION AND CODING OF CONTINUOUS-TONE STILL IMAGES – REQUIREMENTS AND GUIDELINES. 1992-09-18. (PDF, 1,1 MB)