xref: /freebsd/contrib/file/magic/Magdir/jpeg (revision 2008043f386721d58158e37e0d7e50df8095942d)
1
2#------------------------------------------------------------------------------
3# $File: jpeg,v 1.38 2022/12/02 17:42:04 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	belong			0xffd8fff7	JPEG-LS image data
13!:mime	image/jls
14!:ext jls
15>0	use			jpeg
16
170	belong&0xffffff00	0xffd8ff00	JPEG image data
18!:mime	image/jpeg
19!:apple	8BIMJPEG
20!:strength *3
21!:ext jpeg/jpg/jpe/jfif
22>0	use			jpeg
23
240	name		jpeg
25>6	string		JFIF		\b, JFIF standard
26# The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
27# in a vain attempt to add image size reporting for JFIF.  Note that these
28# tests are not fool-proof since some perfectly valid JPEGs are currently
29# impossible to specify in magic(4) format.
30# First, a little JFIF version info:
31>>11	byte		x		\b %d.
32>>12	byte		x		\b%02d
33# Next, the resolution or aspect ratio of the image:
34>>13	byte		0		\b, aspect ratio
35>>13	byte		1		\b, resolution (DPI)
36>>13	byte		2		\b, resolution (DPCM)
37>>14	beshort		x		\b, density %dx
38>>16	beshort		x		\b%d
39>>4	beshort		x		\b, segment length %d
40# Next, show thumbnail info, if it exists:
41>>18	byte		!0		\b, thumbnail %dx
42>>>19	byte		x		\b%d
43>6	string		Exif		\b, Exif standard: [
44>>12	indirect/r	x
45>>12	string		x		\b]
46
47# Jump to the first segment
48>(4.S+4)	use		jpeg_segment
49
50# This uses recursion...
510		name		jpeg_segment
52>0	beshort		0xFFFE
53# Recursion handled by FFE0
54#>>(2.S+2)	use			jpeg_segment
55>>2	pstring/HJ	x		\b, comment: "%s"
56
57>0	beshort		0xFFC0
58>>(2.S+2)	use			jpeg_segment
59>>4	byte		x		\b, baseline, precision %d
60>>7	beshort		x		\b, %dx
61>>5	beshort		x		\b%d
62>>9	byte		x		\b, components %d
63
64>0	beshort		0xFFC1
65>>(2.S+2)	use			jpeg_segment
66>>4	byte		x		\b, extended sequential, precision %d
67>>7	beshort		x		\b, %dx
68>>5	beshort		x		\b%d
69>>9	byte		x		\b, components %d
70
71>0	beshort		0xFFC2
72>>(2.S+2)	use			jpeg_segment
73>>4	byte		x		\b, progressive, precision %d
74>>7	beshort		x		\b, %dx
75>>5	beshort		x		\b%d
76>>9	byte		x		\b, components %d
77
78# Define Huffman Tables
79>0	beshort		0xFFC4
80>>(2.S+2)	use			jpeg_segment
81
82>0	beshort		0xFFE1
83# Recursion handled by FFE0
84#>>(2.S+2)	use			jpeg_segment
85>>4	string		Exif		\b, Exif Standard: [
86>>>10	indirect/r	x
87>>>10	string		x		\b]
88
89# Application specific markers
90>0	beshort&0xFFE0	=0xFFE0
91>>(2.S+2)	use			jpeg_segment
92
93# DB: Define Quantization tables
94# DD: Define Restart interval [XXX: wrong here, it is 4 bytes]
95# D8: Start of image
96# D9: End of image
97# Dn: Restart
98>0	beshort&0xFFD0	=0xFFD0
99>>0	beshort&0xFFE0	!0xFFE0
100>>>(2.S+2)	use			jpeg_segment
101
102#>0	beshort		x		unknown %#x
103#>>(2.S+2)	use			jpeg_segment
104
105# HSI is Handmade Software's proprietary JPEG encoding scheme
106# Update:	Joerg Jenderek
107# URL:		http://fileformats.archiveteam.org/wiki/HSI_JPEG
108# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-hsi1.trid.xml
109# Note:         called by TrID "HSI JPEG bitmap"
1100	string		hsi1		JPEG image data, HSI proprietary
111#!:mime	application/octet-stream
112!:mime	image/x-hsi
113!:ext	hsi/jpg
114
115# From: David Santinoli <david@santinoli.com>
1160	string		\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A	JPEG 2000
117# delete from ./animation (version 1.87) with jP (=6A50h) magic at offset 4
118# From: Johan van der Knijff <johan.vanderknijff@kb.nl>
119# Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes
120# https://github.com/bitsgalore/jp2kMagic
121#
122# Now read value of 'Brand' field, which yields a few possibilities:
123# Update:	Joerg Jenderek
124# URL:		http://fileformats.archiveteam.org/wiki/JP2
125# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpeg2k.trid.xml
126# Note:         called by TrID "JPEG 2000 bitmap"
127>20	string		\x6a\x70\x32\x20	Part 1 (JP2)
128# aliases	image/jpeg2000, image/jpeg2000-image, image/x-jpeg2000-image
129!:mime	image/jp2
130!:ext	jp2
131# URL:		http://fileformats.archiveteam.org/wiki/JPX
132# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpx.trid.xml
133# Note:         called by TrID "JPEG 2000 eXtended bitmap"
134>20	string		\x6a\x70\x78\x20	Part 2 (JPX)
135!:mime	image/jpx
136!:ext	jpf/jpx
137# URL:		http://fileformats.archiveteam.org/wiki/JPM
138# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpm.trid.xml
139# Note:         called by TrID "JPEG 2000 eXtended bitmap"
140>20	string		\x6a\x70\x6d\x20	Part 6 (JPM)
141!:mime	image/jpm
142!:ext	jpm
143# URL:		http://fileformats.archiveteam.org/wiki/MJ2
144# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/v/video-mj2.trid.xml
145# Note:         called by TrID "Motion JPEG 2000 video"
146>20	string		\x6d\x6a\x70\x32	Part 3 (MJ2)
147!:mime	video/mj2
148!:ext	mj2/mjp2
149
150# Type: JPEG 2000 codesream
151# From: Mathieu Malaterre <mathieu.malaterre@gmail.com>
152# Update:	Joerg Jenderek
153# URL:		http://fileformats.archiveteam.org/wiki/JPEG_2000_codestream
154# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jpc.trid.xml
155# Note:         called by TrID "JPEG-2000 Code Stream bitmap"
1560	belong		0xff4fff51						JPEG 2000 codestream
157# value like: 0701h FF50h
158#>45	ubeshort	x	\b, at 45 %#4.4x
159#!:mime	application/octet-stream
160# https://reposcope.com/mimetype/image/x-jp2-codestream
161!:mime	image/x-jp2-codestream
162!:ext	jpc/j2c/j2k
163# MAYBE also JHC like in byte_causal.jhc ?
164# WHAT IS THAT? DEAD ENTRY?
165#45	beshort		0xff52
166
167# JPEG extended range
168# URL:		http://fileformats.archiveteam.org/wiki/JPEG_XR
169# Reference:	https://www.itu.int/rec/T-REC-T.832
170#		http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-wmp.trid.xml
171# Note:         called by TrID "JPEG XR bitmap"
1720	string		\x49\x49\xbc
173# FILE_VERSION_ID; shall be equal to 1; other values are reserved for future use
174>3	byte		1
175# FIRST_IFD_OFFSET; shall be an integer multiple of 2; so skip DROID fmt-590-signature-id-931.wdp
176>>4	lelong%2	0	JPEG-XR
177#!:mime	image/vnd.ms-photo
178!:mime	image/jxr
179# NO example for HDP !
180!:ext	jxr/wdp/hdp
181# MAYBE also WMP ?
182#!:ext	jxr/wdp/hdp/wmp
183# moved from ./images (version 1.205 ), merged and
184# partly verified by XnView `nconvert -info abydos.jxr FLOWER.wdp`
185# example: https://web.archive.org/web/20160403012904/
186# http://shikino.co.jp/solution/upfile/FLOWER.wdp.zip
187>90	bequad		0x574D50484F544F00
188>>98	byte&0x08	=0x08			\b, hard tiling
189>>99	byte&0x80	=0x80			\b, tiling present
190>>99	byte&0x40	=0x40			\b, codestream present
191>>99	byte&0x38	x			\b, spatial xform=
192>>99	byte&0x38	0x00			\bTL
193>>99	byte&0x38	0x08			\bBL
194>>99	byte&0x38	0x10			\bTR
195>>99	byte&0x38	0x18			\bBR
196>>99	byte&0x38	0x20			\bBT
197>>99	byte&0x38	0x28			\bRB
198>>99	byte&0x38	0x30			\bLT
199>>99	byte&0x38	0x38			\bLB
200>>100	byte&0x80	=0x80			\b, short header
201>>>102	beshort+1	x			\b, %d
202>>>104	beshort+1	x			\bx%d
203>>100	byte&0x80	=0x00			\b, long header
204>>>102	belong+1	x			\b, %x
205>>>106	belong+1	x			\bx%x
206>>101	beshort&0xf	x			\b, bitdepth=
207>>>101	beshort&0xf	0x0			\b1-WHITE=1
208>>>101	beshort&0xf	0x1			\b8
209>>>101	beshort&0xf	0x2			\b16
210>>>101	beshort&0xf	0x3			\b16-SIGNED
211>>>101	beshort&0xf	0x4			\b16-FLOAT
212>>>101	beshort&0xf	0x5			\b(reserved 5)
213>>>101	beshort&0xf	0x6			\b32-SIGNED
214>>>101	beshort&0xf	0x7			\b32-FLOAT
215>>>101	beshort&0xf	0x8			\b5
216>>>101	beshort&0xf	0x9			\b10
217>>>101	beshort&0xf	0xa			\b5-6-5
218>>>101	beshort&0xf	0xb			\b(reserved %d)
219>>>101	beshort&0xf	0xc			\b(reserved %d)
220>>>101	beshort&0xf	0xd			\b(reserved %d)
221>>>101	beshort&0xf	0xe			\b(reserved %d)
222>>>101	beshort&0xf	0xf			\b1-BLACK=1
223>>101	beshort&0xf0	x			\b, colorfmt=
224>>>101	beshort&0xf0	0x00			\bYONLY
225>>>101	beshort&0xf0	0x10			\bYUV240
226>>>101	beshort&0xf0	0x20			\bYWV422
227>>>101	beshort&0xf0	0x30			\bYWV444
228>>>101	beshort&0xf0	0x40			\bCMYK
229>>>101	beshort&0xf0	0x50			\bCMYKDIRECT
230>>>101	beshort&0xf0	0x60			\bNCOMPONENT
231>>>101	beshort&0xf0	0x70			\bRGB
232>>>101	beshort&0xf0	0x80			\bRGBE
233>>>101	beshort&0xf0	>0x80			\b(reserved %#x)
234
235# JPEG XL
236# From: Ian Tester
237# Update:	Joerg Jenderek
238# URL:		http://fileformats.archiveteam.org/wiki/JPEG_XL
239# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jxl.trid.xml
240# Note:         called by TrID "JPEG XL bitmap"
2410	string	\xff\x0a				JPEG XL codestream
242!:mime	image/jxl
243!:ext jxl
244
245# JPEG XL (transcoded JPEG file)
246# Update:	Joerg Jenderek
247# URL:		http://fileformats.archiveteam.org/wiki/JPEG_XL
248# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/b/bitmap-jxl-iso.trid.xml
249# Note:         called by TrID "JPEG XL bitmap (ISOBMFF)"
2500	string	\x00\x00\x00\x0cJXL\x20\x0d\x0a\x87\x0a	JPEG XL container
251!:mime	image/jxl
252!:ext jxl
253