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