xref: /minix/external/bsd/file/dist/magic/magdir/jpeg (revision 0a6a1f1d)
1
2#------------------------------------------------------------------------------
3# $File: jpeg,v 1.26 2015/01/02 22:40:27 christos Exp $
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!:mime	image/jpeg
14!:apple	8BIMJPEG
15!:strength +2
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:
22>>11	byte		x		\b %d.
23>>12	byte		x		\b%02d
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
29>>16	beshort		x		\b%d
30>>4	beshort		x		\b, segment length %d
31# Next, show thumbnail info, if it exists:
32>>18	byte		!0		\b, thumbnail %dx
33>>>19	byte		x		\b%d
34>6	string		Exif		\b, Exif standard: [
35>>12	indirect/r	x
36>>12	string		x		\b]
37
38# Jump to the first segment
39>(4.S+4)	use		jpeg_segment
40
41# This uses recursion...
420		name		jpeg_segment
43>0	beshort		0xFFFE
44# Recursion handled by FFE0
45#>>(2.S+2)	use			jpeg_segment
46>>2	pstring/HJ	x		\b, comment: "%s"
47
48>0	beshort		0xFFC0
49>>(2.S+2)	use			jpeg_segment
50>>4	byte		x		\b, baseline, precision %d
51>>7	beshort		x		\b, %dx
52>>5	beshort		x		\b%d
53>>9	byte		x		\b, frames %d
54
55>0	beshort		0xFFC1
56>>(2.S+2)	use			jpeg_segment
57>>4	byte		x		\b, extended sequential, precision %d
58>>7	beshort		x		\b, %dx
59>>5	beshort		x		\b%d
60>>9	byte		x		\b, frames %d
61
62>0	beshort		0xFFC2
63>>(2.S+2)	use			jpeg_segment
64>>4	byte		x		\b, progressive, precision %d
65>>7	beshort		x		\b, %dx
66>>5	beshort		x		\b%d
67>>9	byte		x		\b, frames %d
68
69# Define Huffman Tables
70>0	beshort		0xFFC4
71>>(2.S+2)	use			jpeg_segment
72
73>0	beshort		0xFFE1
74# Recursion handled by FFE0
75#>>(2.S+2)	use			jpeg_segment
76>>4	string		Exif		\b, Exif Standard: [
77>>>10	indirect/r	x
78>>>10	string		x		\b]
79
80# Application specific markers
81>0	beshort&0xFFE0	=0xFFE0
82>>(2.S+2)	use			jpeg_segment
83
84# DB: Define Quantization tables
85# DD: Define Restart interval [XXX: wrong here, it is 4 bytes]
86# D8: Start of image
87# D9: End of image
88# Dn: Restart
89>0	beshort&0xFFD0	=0xFFD0
90>>0	beshort&0xFFE0	!0xFFE0
91>>>(2.S+2)	use			jpeg_segment
92
93#>0	beshort		x		unknown 0x%x
94#>>(2.S+2)	use			jpeg_segment
95
96# HSI is Handmade Software's proprietary JPEG encoding scheme
970	string		hsi1		JPEG image data, HSI proprietary
98
99# From: David Santinoli <david@santinoli.com>
1000	string		\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A	JPEG 2000
101# From: Johan van der Knijff <johan.vanderknijff@kb.nl>
102# Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes
103# https://github.com/bitsgalore/jp2kMagic
104#
105# Now read value of 'Brand' field, which yields a few possibilities:
106>20	string		\x6a\x70\x32\x20	Part 1 (JP2)
107!:mime	image/jp2
108>20	string		\x6a\x70\x78\x20	Part 2 (JPX)
109!:mime	image/jpx
110>20	string		\x6a\x70\x6d\x20	Part 6 (JPM)
111!:mime	image/jpm
112>20	string		\x6d\x6a\x70\x32	Part 3 (MJ2)
113!:mime	video/mj2
114
115# Type: JPEG 2000 codesream
116# From: Mathieu Malaterre <mathieu.malaterre@gmail.com>
1170	belong		0xff4fff51						JPEG 2000 codestream
11845	beshort		0xff52
119