2 #------------------------------------------------------------------------------
6 # 0 string \377\330\377\340 JPEG file
7 # 0 string \377\330\377\356 JPG file
9 # both of which turn into "JPEG image data" here.
11 0 beshort 0xffd8 JPEG image data
12 >6 string JFIF \b, JFIF standard
13 >6 string Exif \b, EXIF standard
14 # The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
15 # in a vain attempt to add image size reporting for JFIF. Note that these
16 # tests are not fool-proof since some perfectly valid JPEGs are currently
17 # impossible to specify in magic(4) format.
18 # First, a little JFIF version info:
21 # Next, the resolution or aspect ratio of the image:
22 >13 byte 0 \b, aspect ratio
23 >13 byte 1 \b, resolution (DPI)
24 >13 byte 2 \b, resolution (DPCM)
25 #>4 beshort x \b, segment length %d
26 # Next, show thumbnail info, if it exists:
27 >18 byte !0 \b, thumbnail %dx
29 # Here things get sticky. We can do ONE MORE marker segment with
30 # indirect addressing, and that's all. It would be great if we could
31 # do pointer arithemetic like in an assembler language. Christos?
32 # And if there was some sort of looping construct to do searches, plus a few
33 # named accumulators, it would be even more effective...
34 # At least we can show a comment if no other segments got inserted before:
36 >>(4.S+8) string >\0 \b, "%s"
37 #>(4.S+5) byte 0xFE \b, comment
38 #>>(4.S+6) beshort x \b length=%d
39 #>>(4.S+8) string >\0 \b, "%s"
40 # Or, we can show the encoding type (I've included only the three most common)
41 # and image dimensions if we are lucky and the SOFn (image segment) is here:
42 >(4.S+5) byte 0xC0 \b, baseline
43 >>(4.S+6) byte x \b, precision %d
44 >>(4.S+7) beshort x \b, %dx
45 >>(4.S+9) beshort x \b%d
46 >(4.S+5) byte 0xC1 \b, extended sequential
47 >>(4.S+6) byte x \b, precision %d
48 >>(4.S+7) beshort x \b, %dx
49 >>(4.S+9) beshort x \b%d
50 >(4.S+5) byte 0xC2 \b, progressive
51 >>(4.S+6) byte x \b, precision %d
52 >>(4.S+7) beshort x \b, %dx
53 >>(4.S+9) beshort x \b%d
54 # I've commented-out quantisation table reporting. I doubt anyone cares yet.
55 #>(4.S+5) byte 0xDB \b, quantisation table
56 #>>(4.S+6) beshort x \b length=%d
57 >14 beshort x \b, %d x
60 # HSI is Handmade Software's proprietary JPEG encoding scheme
61 0 string hsi1 JPEG image data, HSI proprietary