Merge from vendor branch BIND:
[dragonfly.git] / contrib / file-4 / magic / Magdir / jpeg
1
2 #------------------------------------------------------------------------------
3 # JPEG images
4 # SunOS 5.5.1 had
5 #
6 #       0       string          \377\330\377\340        JPEG file
7 #       0       string          \377\330\377\356        JPG file
8 #
9 # both of which turn into "JPEG image data" here.
10 #
11 0       beshort         0xffd8          JPEG image data
12 >6      string          JFIF            \b, JFIF standard
13 # The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
14 # in a vain attempt to add image size reporting for JFIF.  Note that these
15 # tests are not fool-proof since some perfectly valid JPEGs are currently
16 # impossible to specify in magic(4) format.
17 # First, a little JFIF version info:
18 >>11    byte            x               \b %d.
19 >>12    byte            x               \b%02d
20 # Next, the resolution or aspect ratio of the image:
21 #>>13   byte            0               \b, aspect ratio
22 #>>13   byte            1               \b, resolution (DPI)
23 #>>13   byte            2               \b, resolution (DPCM)
24 #>>4    beshort         x               \b, segment length %d
25 # Next, show thumbnail info, if it exists:
26 >>18    byte            !0              \b, thumbnail %dx
27 >>>19   byte            x               \b%d
28
29 # EXIF moved down here to avoid reporting a bogus version number,
30 # and EXIF version number printing added.
31 #   - Patrik R=E5dman <patrik+file-magic@iki.fi>
32 >6      string          Exif            \b, EXIF standard
33 # Look for EXIF IFD offset in IFD 0, and then look for EXIF version tag in EXIF IFD.
34 # All possible combinations of entries have to be enumerated, since no looping
35 # is possible. And both endians are possible...
36 # The combinations included below are from real-world JPEGs.
37 # Little-endian
38 >>12    string          II              
39 # IFD 0 Entry #5:
40 >>>70   leshort         0x8769          
41 # EXIF IFD Entry #1:
42 >>>>(78.l+14)   leshort 0x9000          
43 >>>>>(78.l+23)  byte    x               %c
44 >>>>>(78.l+24)  byte    x               \b.%c
45 >>>>>(78.l+25)  byte    !0x30           \b%c
46 # IFD 0 Entry #9:
47 >>>118  leshort         0x8769          
48 # EXIF IFD Entry #3:
49 >>>>(126.l+38)  leshort 0x9000          
50 >>>>>(126.l+47) byte    x               %c
51 >>>>>(126.l+48) byte    x               \b.%c
52 >>>>>(126.l+49) byte    !0x30           \b%c
53 # IFD 0 Entry #10
54 >>>130  leshort         0x8769          
55 # EXIF IFD Entry #3:
56 >>>>(138.l+38)  leshort 0x9000          
57 >>>>>(138.l+47) byte    x               %c
58 >>>>>(138.l+48) byte    x               \b.%c
59 >>>>>(138.l+49) byte    !0x30           \b%c
60 # EXIF IFD Entry #4:
61 >>>>(138.l+50)  leshort 0x9000          
62 >>>>>(138.l+59) byte    x               %c
63 >>>>>(138.l+60) byte    x               \b.%c
64 >>>>>(138.l+61) byte    !0x30           \b%c
65 # EXIF IFD Entry #5:
66 >>>>(138.l+62)  leshort 0x9000          
67 >>>>>(138.l+71) byte    x               %c
68 >>>>>(138.l+72) byte    x               \b.%c
69 >>>>>(138.l+73) byte    !0x30           \b%c
70 # IFD 0 Entry #11
71 >>>142  leshort         0x8769          
72 # EXIF IFD Entry #3:
73 >>>>(150.l+38)  leshort 0x9000          
74 >>>>>(150.l+47) byte    x               %c
75 >>>>>(150.l+48) byte    x               \b.%c
76 >>>>>(150.l+49) byte    !0x30           \b%c
77 # EXIF IFD Entry #4:
78 >>>>(150.l+50)  leshort 0x9000          
79 >>>>>(150.l+59) byte    x               %c
80 >>>>>(150.l+60) byte    x               \b.%c
81 >>>>>(150.l+61) byte    !0x30           \b%c
82 # EXIF IFD Entry #5:
83 >>>>(150.l+62)  leshort 0x9000          
84 >>>>>(150.l+71) byte    x               %c
85 >>>>>(150.l+72) byte    x               \b.%c
86 >>>>>(150.l+73) byte    !0x30           \b%c
87 # Big-endian
88 >>12    string          MM              
89 # IFD 0 Entry #9:
90 >>>118  beshort         0x8769          
91 # EXIF IFD Entry #1:
92 >>>>(126.L+14)  beshort 0x9000          
93 >>>>>(126.L+23) byte    x               %c
94 >>>>>(126.L+24) byte    x               \b.%c
95 >>>>>(126.L+25) byte    !0x30           \b%c
96 # EXIF IFD Entry #3:
97 >>>>(126.L+38)  beshort 0x9000          
98 >>>>>(126.L+47) byte    x               %c
99 >>>>>(126.L+48) byte    x               \b.%c
100 >>>>>(126.L+49) byte    !0x30           \b%c
101 # IFD 0 Entry #10
102 >>>130  beshort         0x8769          
103 # EXIF IFD Entry #3:
104 >>>>(138.L+38)  beshort 0x9000          
105 >>>>>(138.L+47) byte    x               %c
106 >>>>>(138.L+48) byte    x               \b.%c
107 >>>>>(138.L+49) byte    !0x30           \b%c
108 # EXIF IFD Entry #5:
109 >>>>(138.L+62)  beshort 0x9000          
110 >>>>>(138.L+71) byte    x               %c
111 >>>>>(138.L+72) byte    x               \b.%c
112 >>>>>(138.L+73) byte    !0x30           \b%c
113 # IFD 0 Entry #11
114 >>>142  beshort         0x8769          
115 # EXIF IFD Entry #4:
116 >>>>(150.L+50)  beshort 0x9000          
117 >>>>>(150.L+59) byte    x               %c
118 >>>>>(150.L+60) byte    x               \b.%c
119 >>>>>(150.L+61) byte    !0x30           \b%c
120 # Here things get sticky.  We can do ONE MORE marker segment with
121 # indirect addressing, and that's all.  It would be great if we could
122 # do pointer arithemetic like in an assembler language.  Christos?
123 # And if there was some sort of looping construct to do searches, plus a few
124 # named accumulators, it would be even more effective...
125 # At least we can show a comment if no other segments got inserted before:
126 >(4.S+5)        byte            0xFE
127 >>(4.S+8)       string          >\0             \b, comment: "%s"
128 #>(4.S+5)       byte            0xFE            \b, comment
129 #>>(4.S+6)      beshort         x               \b length=%d
130 #>>(4.S+8)      string          >\0             \b, "%s"
131 # Or, we can show the encoding type (I've included only the three most common)
132 # and image dimensions if we are lucky and the SOFn (image segment) is here:
133 >(4.S+5)        byte            0xC0            \b, baseline
134 >>(4.S+6)       byte            x               \b, precision %d
135 >>(4.S+7)       beshort         x               \b, %dx
136 >>(4.S+9)       beshort         x               \b%d
137 >(4.S+5)        byte            0xC1            \b, extended sequential
138 >>(4.S+6)       byte            x               \b, precision %d
139 >>(4.S+7)       beshort         x               \b, %dx
140 >>(4.S+9)       beshort         x               \b%d
141 >(4.S+5)        byte            0xC2            \b, progressive
142 >>(4.S+6)       byte            x               \b, precision %d
143 >>(4.S+7)       beshort         x               \b, %dx
144 >>(4.S+9)       beshort         x               \b%d
145 # I've commented-out quantisation table reporting.  I doubt anyone cares yet.
146 #>(4.S+5)       byte            0xDB            \b, quantisation table
147 #>>(4.S+6)      beshort         x               \b length=%d
148 #>14    beshort         x               \b, %d x
149 #>16    beshort         x               \b %d
150
151 # HSI is Handmade Software's proprietary JPEG encoding scheme
152 0       string          hsi1            JPEG image data, HSI proprietary
153
154 # From: David Santinoli <david@santinoli.com>
155 0       string          \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A        JPEG 2000 image data