Image::MetaData::JPEG::Structures 0.15 review

by on

Image::MetaData::JPEG::Structures is a Perl module that describes the structure of a JPEG file; it is an appendix to the main manual

License: Perl Artistic License
File size: 285K
Developer: Stefano Bettelli
0 stars award from

Image::MetaData::JPEG::Structures is a Perl module that describes the structure of a JPEG file; it is an appendix to the main manual page of the Image::MetaData::JPEG module, which the reader should refer to for further details and the general scope.


The JPEG (Joint Photographic Experts Group) ISO standard is a lossy image compression mechanism developed before 1990, designed for compressing colour or gray-scale photo-realistic images (it performs poorly on line-art drawings). The JPEG mechanism is designed to exploit known limitations of the human eye, in particular the fact that colour changes are perceived less accurately than changes in brightness.

Note that although the "baseline" JPEG format is patent-free, there are patents associated with some optional features, namely arithmetic coding and hierarchical storage. For this reason, these optional features are never used on the Web (good job, patent fans ...). JPEG refers only to a class of compression algorithms, not to a specific file format. In order to produce files with embedded JPEG streams, a number of file format (semi-)standards have been adapted or devised, some of which are listed in the format section. The structure of a well formed JPEG file can be described by the following pseudo production rules (for sake of simplicity, some additional constraints between tables and SOF segments are neglected).

JPEG --> (SOI)(misc)*(image)?(EOI)
(image) --> (hierarch.)|(non-hier.)
(hierarch.) --> (DHP)(frame)+
(frame) --> (misc)*(EXP)?(non-hier.)
(non-hier.) --> (SOF)(scan)+
(scan) --> (misc)*(SOS)(data)*(ECS)(DNL)?
(data) --> (ECS)(RST)
(misc) --> (DQT)|(DHT)|(DAC)|(DRI)|(COM)|(APP)

(SOI) = Start Of Image
(EOI) = End Of Image
(SOF) = Start Of Frame header (10 types)
(SOS) = Start Of Scan header
(ECS) = Entropy Coded Segment (row data, not a real segment)
(DNL) = Define Number of Lines segment
(DHP) = Define Hierarchical P??? segment
(EXP) = EXPansion segment
(RST) = ReSTart segment (8 types)
(DQT) = Define Quantisation Table
(DHT) = Define Huffman coding Table
(DAC) = Define Arithmetic coding Table
(DRI) = Define Restart Interval
(COM) = COMment segment
(APP) = APPlication segment

This package does not check that a JPEG file is really correct; it accepts a looser syntax, were segments and ECS blocks are just contiguous (basically, because it does not need to display the image!). All meta-data information is concentrated in the (COM*) and (APP) Segments, exception made for some records in the (SOF*) segment (e.g. image dimensions).

Reference: B< "Digital compression and coding of continuous-tone still
images: requirements and guidelines", CCITT recommend. T.81, 1992,
The International Telegraph and Telephone Consultative Committee,
standard ISO/IEC IS 10918-1 or ITU-T Recommendation T.81 >.
Also: B< "The JPEG still picture compression standard", G.K.Wallace,
1991, IEEE Transactions on Consumer Electronics >.


Image::MetaData::JPEG::Structures 0.15 search tags