OUR FREE ONLINE TOOLS: Imgur Downloader Gfycat Downloader Vimeo Downloader Instagram Downloader (new) Find Subtitles File Detective Subtitle Converter File Extensions Image Converter
Images \ Raster images \ .jpg - Joint Photographic Experts Group JFIF

What is .jpg file?

Joint Photographic Experts Group JFIF is a raster image. Images are compressed.
File extension is .jpg.

Software handling .jpg files

Rest7 Free Online Converter

Structure of .jpg images

JPEG images don't have a header. They have segments.
Each segment has a different meaning and each starts with 0xFF. After this byte there is another byte which defined segment meaning.

First segment SOI (FF D8)

This is the first segment of JPEG image. It's just 2 bytes long.
Name Type Description
Marker UInt16 = 0xFF 0xD8
If a file has these 2 bytes at the beginning then it's most likely a JPEG image.

(Should be second) segment APP0 (FF E0)

Name Type Description
Marker UInt16 = 0xFF 0xE0
Length UInt16 Length of this segment (excluding first 2 bytes- the Marker)
Identifier Char8[5] = 'JFIF\0'
MajorVersion UInt8 Eg. 01
MinorVersion UInt8 Eg. 02
DensityUnits UInt8 0 = no units, 1 = pixels per inch (2.54 cm), 2 = pixels per cm
XDensity UInt16 Horizontal pixel density. Must not be 0
YDensity UInt16 Vertical pixel density. Must not be 0
XThumbnail UInt8 Horizontal pixel density of a thumbnail. Can be 0
YThumbnail UInt8 Vertical pixel density a thumbnail. Can be 0
Thumbnail ... Uncompressed 24 bit RGB. Number of pixels = XThumbnail * Ythumbnail
So a 200x100 thumbnail needs 60000 bytes.

Additional APP0 segment (FF E0)

This segment is optional. If it is present it should be after the first APP0 segment.
Name Type Description
Marker UInt16 = 0xFF 0xE0
Length UInt16 Length of this segment (excluding first 2 bytes- the Marker)
Identifier Char8[5] = 'JFXX\0'
ThumbnailFormat UInt8 10 = JPEG, 11 = 8 bpp palettized, 13 = RGB 24 bpp
Thumbnail ... Depends on the thumbnail format
If thumbnail format = 10 then a new segment follows:
Name Type Description
Marker UInt16 = 0xFF 0xD8
Thumbnail ... JIF format image using YCbCr or just Y, and must not contain JFIF or JFXX segments
EndOfSegment UInt16 = 0xFF 0xD9
Or if thumbnail format = 11 then a new segment follows:
Name Type Description
Xthumbnail UInt8 Width of thumbnail
Ythumbnail UInt8 Height of thumbnail
ThumbnailPalette UInt24[256] 256 entries of the palette. Each entry is 24 bit RGB
Thumbnail ... Size in bytes = Xthumbnail × Ythumbnail
OR if thumbnail format = 13 then a new segment follows:
Name Type Description
Xthumbnail UInt8 Width of thumbnail
Ythumbnail UInt8 Height of thumbnail
Thumbnail ... Size in bytes = 3 * Xthumbnail × Ythumbnail, (RGB 24 bit)

(Often second or third) segment APP1 (FF E1)

This is used to store EXIF data. If you don't need EXIF data you can skip parsking this segment.
Name Type Description
Marker UInt16 = 0xFF 0xE1
Length UInt16 Length of this segment (excluding first 2 bytes- the Marker)
ExifData ... Size in bytes = "Length"

Segment COM (FF FE)

This is an optional comment. If you don't need the comment can skip parsking this segment.
Name Type Description
Marker UInt16 = 0xFF 0xFE
Length UInt16 Length of this segment (excluding first 2 bytes- the Marker)
Comment ... Size in bytes = "Length"

Segment SOF0 (FF C0)

Start Of Frame. If this segment is present it means the image is baseline DCT-based
Name Type Description
Marker UInt16 = 0xFF 0xC0
Length UInt16 Length of this segment (excluding first 2 bytes- the Marker)
BitsPerSample UInt8 Usually 8, 12 and 16 are rarely supported
Width UInt16
Height UInt16
ComponentsCount UInt8 1 = grayscale, 3 = color YcbCr or YIQ, 4 = CMYK
Compontents UInt24[ComponentsCount]

Segment SOF2 (FF C2)

Start Of Frame. If this segment is present it means the image is progressive DCT-based
Name Type Description
Marker UInt16 = 0xFF 0xC2
Length UInt16 Length of this segment (excluding first 2 bytes- the Marker)
Data ...

Segment DHT (FF C4)

Define Huffman Table

Segment DQT (FF DB)

Define Quantization Table

Segment DAC (FF ??)

Define Arithmetic Table
Most programs don't support this arithmetic-coded images.

Segment SOS (FF DA)

Start Of Scan

Last segment EOI (FF D9)

This is the last segment of JPEG image. It's just 2 bytes long.
Name Type Description
Marker UInt16 = 0xFF 0xD9

Data types:
UInt8, UInt16, UInt32, UInt64 - Unsigned Integer 8 bit, 16 bit, 32 bit, 64 bit
Int8, Int16, Int32, Int64 - Signed Integer 8 bit, 16 bit, 32 bit, 64 bit
UMint16, UMint32 - Unsigned Motorola Integer 16 bit, 32 bit (Big Endian)
Char8, Char16 - Char 8 bit, 16 bit

Real world .jpg samples

Here are some real world example pictures.



Rest7 Webtools Contact Usage Agreements Image Converter

Some icons by Freepik (CC BY 3.0)

Copyright © 2015-8 by rest7.com. All rights reserved.