2 #------------------------------------------------------------------------------
3 # $File: jpeg,v 1.25 2015/01/02 16:56:50 christos Exp $
7 # 0 string \377\330\377\340 JPEG file
8 # 0 string \377\330\377\356 JPG file
10 # both of which turn into "JPEG image data" here.
12 0 beshort 0xffd8 JPEG image data
16 >6 string JFIF \b, JFIF standard
17 # The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
18 # in a vain attempt to add image size reporting for JFIF. Note that these
19 # tests are not fool-proof since some perfectly valid JPEGs are currently
20 # impossible to specify in magic(4) format.
21 # First, a little JFIF version info:
24 # Next, the resolution or aspect ratio of the image:
25 >>13 byte 0 \b, aspect ratio
26 >>13 byte 1 \b, resolution (DPI)
27 >>13 byte 2 \b, resolution (DPCM)
28 >>14 beshort x \b, density %dx
30 >>4 beshort x \b, segment length %d
31 # Next, show thumbnail info, if it exists:
32 >>18 byte !0 \b, thumbnail %dx
34 >6 string Exif \b, Exif standard: [
38 # Jump to the first segment
39 >(4.S+4) use jpeg_segment
41 # This uses recursion...
44 >>(2.S+2) use jpeg_segment
45 >>2 pstring/HJ x \b, comment: "%s"
48 >>(2.S+2) use jpeg_segment
49 >>4 byte x \b, baseline, precision %d
52 >>9 byte x \b, frames %d
55 >>(2.S+2) use jpeg_segment
56 >>4 byte x \b, extended sequential, precision %d
59 >>9 byte x \b, frames %d
62 >>(2.S+2) use jpeg_segment
63 >>4 byte x \b, progressive, precision %d
66 >>9 byte x \b, frames %d
68 # Define Huffman Tables
70 >>(2.S+2) use jpeg_segment
73 #>>(2.S+2) use jpeg_segment
74 >>4 string Exif \b, Exif Standard: [
78 # Application specific markers
79 >0 beshort&0xFFE0 =0xFFE0
80 >>(2.S+2) use jpeg_segment
82 # DB: Define Quantization tables
83 # DD: Define Restart interval [XXX: wrong here, it is 4 bytes]
87 >0 beshort&0xFFD0 =0xFFD0
88 >>(2.S+2) use jpeg_segment
90 #>0 beshort x unknown 0x%x
91 #>>(2.S+2) use jpeg_segment
93 # HSI is Handmade Software's proprietary JPEG encoding scheme
94 0 string hsi1 JPEG image data, HSI proprietary
96 # From: David Santinoli <david@santinoli.com>
97 0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000
98 # From: Johan van der Knijff <johan.vanderknijff@kb.nl>
99 # Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes
100 # https://github.com/bitsgalore/jp2kMagic
102 # Now read value of 'Brand' field, which yields a few possibilities:
103 >20 string \x6a\x70\x32\x20 Part 1 (JP2)
105 >20 string \x6a\x70\x78\x20 Part 2 (JPX)
107 >20 string \x6a\x70\x6d\x20 Part 6 (JPM)
109 >20 string \x6d\x6a\x70\x32 Part 3 (MJ2)
112 # Type: JPEG 2000 codesream
113 # From: Mathieu Malaterre <mathieu.malaterre@gmail.com>
114 0 belong 0xff4fff51 JPEG 2000 codestream