Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
JPEG File Interchange Format
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== File format structure == A JFIF file consists of a sequence of markers or marker segments (for details refer to [[JPEG#Syntax and structure|JPEG, Syntax and structure]]). The markers are defined in part 1 of the [[JPEG]] Standard.<ref name="itu_t81" /> Each marker consists of two bytes: an <code>FF</code> byte followed by a byte which is not equal to <code>00</code> or <code>FF</code> 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: <code>FF ''xx'' ''s1'' ''s2'' ''[data bytes]''</code> The bytes ''s1'' and ''s2'' are taken together to represent a [[Endianness|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 <math>256 \cdot s1 + s2 - 2</math>. 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.<ref name="hamilton_1992" /> So a JFIF file will have the following structure: {| class="wikitable" |- !colspan="3" style="text-align:left"|JFIF file structure |- !style="text-align:left"|Segment !! style="text-align:left"|Code !! style="text-align:left"|Description |- | SOI || <code>FF D8</code> || Start of Image |- | JFIF-APP0 || <code>FF E0 ''s1'' ''s2'' 4A 46 49 46 00 ...</code> || see below |- | JFXX-APP0 || <code>FF E0 ''s1'' ''s2'' 4A 46 58 58 00 ...</code> || optional, see below |- | colspan="3" | β¦ additional marker segments<br /> (for example SOF, DHT, COM) |- | SOS || <code>FF DA</code> || Start of Scan |- | || compressed image data || |- | EOI || <code>FF D9</code> || 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. {| class="wikitable" |- !colspan="3" style="text-align:left"|JFIF APP0 marker segment |- ! style="text-align:left"|Field || style="text-align:left"|Size (bytes) || style="text-align:left"|Description |- | APP0 marker || 2 || <code>FF E0</code> |- | Length || 2 || Length of segment excluding APP0 marker |- | Identifier || 5 || <code>4A 46 49 46 00</code> = "JFIF" in [[ASCII]], terminated by a null byte |- | JFIF version || 2 || First byte for major version, second byte for minor version (<code>01 02</code> for 1.02) |- | Density units || 1 || Units for the following pixel density fields * <code>00</code> : No units; width:height [[pixel aspect ratio]] = Ydensity:Xdensity * <code>01</code> : Pixels per inch (2.54 cm) * <code>02</code> : Pixels per centimeter |- | 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-1, Gn-1, Bn-1; 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. {| class="wikitable" |- !colspan="3" style="text-align:left"|JFIF extension APP0 marker segment |- ! style="text-align:left"|Field || style="text-align:left"|Size (bytes) || style="text-align:left"|Description |- | APP0 marker || 2 || <code>FF E0</code> |- | Length || 2 || Length of segment excluding APP0 marker |- | Identifier || 5 || <code>4A 46 58 58 00</code> = "JFXX" in [[ASCII]], terminated by a null byte |- | Thumbnail format || 1 || Specifies what data format is used for the following embedded thumbnail: * <code>10</code> : JPEG format * <code>11</code> : 1 byte per pixel palettized format * <code>13</code> : 3 byte per pixel RGB format |- | Thumbnail data || variable || Depends on the thumbnail format, see below |} The thumbnail data depends on the thumbnail format as follows: {| class="wikitable" |- !colspan="3" style="text-align:left"| Thumbnail stored using JPEG encoding |- ! style="text-align:left"|Field || style="text-align:left"|Size (bytes) || style="text-align:left"|Description |- | SOI || 2 || <code>FF D8</code> |- | || variable || Must be JIF format using YCbCr or just Y, and must not contain JFIF or JFXX segments |- | EOI || 2 || <code>FF D9</code> |} {| class="wikitable" |- !colspan="3" style="text-align:left"| Thumbnail stored using one byte per pixel |- ! style="text-align:left"|Field || style="text-align:left"|Size (bytes) || style="text-align:left"|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 |} {| class="wikitable" |- !colspan="3" style="text-align:left"| Thumbnail stored using three byte per pixel |- ! style="text-align:left"|Field || style="text-align:left"|Size (bytes) || style="text-align:left"|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-1, Gn-1, Bn-1; with ''n'' = Xthumbnail Γ Ythumbnail |}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
JPEG File Interchange Format
(section)
Add topic