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