images revision 74784
168349Sobrien
268349Sobrien#------------------------------------------------------------------------------
368349Sobrien# images:  file(1) magic for image formats (see also "iff")
468349Sobrien#
568349Sobrien# originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
668349Sobrien# additions by janl@ifi.uio.no as well as others. Jan also suggested
768349Sobrien# merging several one- and two-line files into here.
868349Sobrien#
968349Sobrien# little magic: PCX (first byte is 0x0a)
1068349Sobrien
1168349Sobrien# Targa - matches `povray', `ppmtotga' and `xv' outputs
1268349Sobrien# by Philippe De Muyter <phdm@macqel.be>
1368349Sobrien# at 2, byte ImgType must be 1, 2, 3, 9, 10 or 11
1468349Sobrien# at 1, byte CoMapType must be 1 if ImgType is 1 or 9, 0 otherwise
1568349Sobrien# at 3, leshort Index is 0 for povray, ppmtotga and xv outputs
1668349Sobrien# `xv' recognizes only a subset of the following (RGB with pixelsize = 24)
1768349Sobrien# `tgatoppm' recognizes a superset (Index may be anything)
1868349Sobrien1	belong&0xfff7ffff	0x01010000	Targa image data - Map
1968349Sobrien>2	byte&8			8		- RLE
2068349Sobrien1	belong&0xfff7ffff	0x00020000	Targa image data - RGB
2168349Sobrien>2	byte&8			8		- RLE
2268349Sobrien1	belong&0xfff7ffff	0x00030000	Targa image data - Mono
2368349Sobrien>2	byte&8			8		- RLE
2468349Sobrien
2568349Sobrien# PBMPLUS images
2668349Sobrien# The next byte following the magic is always whitespace.
2769216Sobrien0	string		P1		Netpbm PBM image text
2869216Sobrien0	string		P2		Netpbm PGM image text
2969216Sobrien0	string		P3		Netpbm PPM image text
3069216Sobrien0	string		P4		Netpbm PBM "rawbits" image data
3169216Sobrien0	string		P5		Netpbm PGM "rawbits" image data
3269216Sobrien0	string		P6		Netpbm PPM "rawbits" image data
3369216Sobrien0	string		P7		Netpbm PAM image file
3468349Sobrien
3569216Sobrien# From: bryanh@giraffe-data.com (Bryan Henderson)
3669216Sobrien0	string		\117\072	Solitaire Image Recorder format
3769216Sobrien>4	string		\013		MGI Type 11
3869216Sobrien>4	string		\021		MGI Type 17
3969216Sobrien0	string		.MDA		MicroDesign data
4069216Sobrien>21	byte		48		version 2
4169216Sobrien>21	byte		51		version 3
4269216Sobrien0	string		.MDP		MicroDesign page data
4369216Sobrien>21	byte		48		version 2
4469216Sobrien>21	byte		51		version 3
4569216Sobrien
4668349Sobrien# NIFF (Navy Interchange File Format, a modification of TIFF) images
4768349Sobrien0	string		IIN1		NIFF image data
4868349Sobrien
4968349Sobrien# Tag Image File Format, from Daniel Quinlan (quinlan@yggdrasil.com)
5068349Sobrien# The second word of TIFF files is the TIFF version number, 42, which has
5168349Sobrien# never changed.  The TIFF specification recommends testing for it.
5268349Sobrien0	string		MM\x00\x2a	TIFF image data, big-endian
5368349Sobrien0	string		II\x2a\x00	TIFF image data, little-endian
5468349Sobrien
5568349Sobrien# PNG [Portable Network Graphics, or "PNG's Not GIF"] images
5668349Sobrien# (Greg Roelofs, newt@uchicago.edu)
5768349Sobrien# (Albert Cahalan, acahalan@cs.uml.edu)
5868349Sobrien#
5968349Sobrien# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ...
6068349Sobrien#
6168349Sobrien0	string		\x89PNG		PNG image data,
6268349Sobrien>4	belong		!0x0d0a1a0a	CORRUPTED,
6368349Sobrien>4	belong		0x0d0a1a0a
6468349Sobrien>>16	belong		x		%ld x
6568349Sobrien>>20	belong		x		%ld,
6668349Sobrien>>24	byte		x		%d-bit
6768349Sobrien>>25	byte		0		grayscale,
6868349Sobrien>>25	byte		2		\b/color RGB,
6968349Sobrien>>25	byte		3		colormap,
7068349Sobrien>>25	byte		4		gray+alpha,
7168349Sobrien>>25	byte		6		\b/color RGBA,
7268349Sobrien#>>26	byte		0		deflate/32K,
7368349Sobrien>>28	byte		0		non-interlaced
7468349Sobrien>>28	byte		1		interlaced
7568349Sobrien1	string		PNG		PNG image data, CORRUPTED
7668349Sobrien
7768349Sobrien# GIF
7868349Sobrien0	string		GIF8		GIF image data
7968349Sobrien>4	string		7a		\b, version 8%s,
8068349Sobrien>4	string		9a		\b, version 8%s,
8168349Sobrien>6	leshort		>0		%hd x
8268349Sobrien>8	leshort		>0		%hd,
8368349Sobrien#>10	byte		&0x80		color mapped,
8468349Sobrien#>10	byte&0x07	=0x00		2 colors
8568349Sobrien#>10	byte&0x07	=0x01		4 colors
8668349Sobrien#>10	byte&0x07	=0x02		8 colors
8768349Sobrien#>10	byte&0x07	=0x03		16 colors
8868349Sobrien#>10	byte&0x07	=0x04		32 colors
8968349Sobrien#>10	byte&0x07	=0x05		64 colors
9068349Sobrien#>10	byte&0x07	=0x06		128 colors
9168349Sobrien#>10	byte&0x07	=0x07		256 colors
9268349Sobrien
9368349Sobrien# ITC (CMU WM) raster files.  It is essentially a byte-reversed Sun raster,
9468349Sobrien# 1 plane, no encoding.
9568349Sobrien0	string		\361\0\100\273	CMU window manager raster image data
9668349Sobrien>4	lelong		>0		%d x
9768349Sobrien>8	lelong		>0		%d,
9868349Sobrien>12	lelong		>0		%d-bit
9968349Sobrien
10068349Sobrien# Magick Image File Format
10168349Sobrien0	string		id=ImageMagick	MIFF image data
10268349Sobrien
10368349Sobrien# Artisan
10468349Sobrien0	long		1123028772	Artisan image data
10568349Sobrien>4	long		1		\b, rectangular 24-bit
10668349Sobrien>4	long		2		\b, rectangular 8-bit with colormap
10768349Sobrien>4	long		3		\b, rectangular 32-bit (24-bit with matte)
10868349Sobrien
10968349Sobrien# FIG (Facility for Interactive Generation of figures), an object-based format
11068349Sobrien0	string		#FIG		FIG image text
11168349Sobrien>5	string		x		\b, version %.3s
11268349Sobrien
11368349Sobrien# PHIGS
11468349Sobrien0	string		ARF_BEGARF		PHIGS clear text archive
11568349Sobrien0	string		@(#)SunPHIGS		SunPHIGS
11668349Sobrien# version number follows, in the form m.n
11768349Sobrien>40	string		SunBin			binary
11868349Sobrien>32	string		archive			archive
11968349Sobrien
12068349Sobrien# GKS (Graphics Kernel System)
12168349Sobrien0	string		GKSM		GKS Metafile
12268349Sobrien>24	string		SunGKS		\b, SunGKS
12368349Sobrien
12468349Sobrien# CGM image files
12568349Sobrien0	string		BEGMF		clear text Computer Graphics Metafile
12668349Sobrien# XXX - questionable magic
12768349Sobrien0	beshort&0xffe0	0x0020		binary Computer Graphics Metafile
12868349Sobrien0	beshort		0x3020		character Computer Graphics Metafile
12968349Sobrien
13068349Sobrien# MGR bitmaps  (Michael Haardt, u31b3hs@pool.informatik.rwth-aachen.de)
13168349Sobrien0	string	yz	MGR bitmap, modern format, 8-bit aligned
13268349Sobrien0	string	zz	MGR bitmap, old format, 1-bit deep, 16-bit aligned
13368349Sobrien0	string	xz	MGR bitmap, old format, 1-bit deep, 32-bit aligned
13468349Sobrien0	string	yx	MGR bitmap, modern format, squeezed
13568349Sobrien
13668349Sobrien# Fuzzy Bitmap (FBM) images
13768349Sobrien0	string		%bitmap\0	FBM image data
13868349Sobrien>30	long		0x31		\b, mono
13968349Sobrien>30	long		0x33		\b, color
14068349Sobrien
14168349Sobrien# facsimile data
14268349Sobrien1	string		PC\ Research,\ Inc	group 3 fax data
14368349Sobrien>29	byte		0		\b, normal resolution (204x98 DPI)
14468349Sobrien>29	byte		1		\b, fine resolution (204x196 DPI)
14568349Sobrien
14668349Sobrien# PC bitmaps (OS/2, Windoze BMP files)  (Greg Roelofs, newt@uchicago.edu)
14768349Sobrien0	string		BM		PC bitmap data
14868349Sobrien>14	leshort		12		\b, OS/2 1.x format
14968349Sobrien>>18	leshort		x		\b, %d x
15068349Sobrien>>20	leshort		x		%d
15168349Sobrien>14	leshort		64		\b, OS/2 2.x format
15268349Sobrien>>18	leshort		x		\b, %d x
15368349Sobrien>>20	leshort		x		%d
15468349Sobrien>14	leshort		40		\b, Windows 3.x format
15568349Sobrien>>18	lelong		x		\b, %d x
15668349Sobrien>>22	lelong		x		%d x
15768349Sobrien>>28	leshort		x		%d
15868349Sobrien0	string		IC		PC icon data
15968349Sobrien0	string		PI		PC pointer image data
16068349Sobrien0	string		CI		PC color icon data
16168349Sobrien0	string		CP		PC color pointer image data
16268349Sobrien# Conflicts with other entries [BABYL]
16368349Sobrien#0	string		BA		PC bitmap array data
16468349Sobrien
16568349Sobrien# XPM icons (Greg Roelofs, newt@uchicago.edu)
16668349Sobrien# note possible collision with C/REXX entry in c-lang; currently commented out
16768349Sobrien0	string		/*\ XPM\ */	X pixmap image text
16868349Sobrien
16968349Sobrien# Utah Raster Toolkit RLE images (janl@ifi.uio.no)
17068349Sobrien0	leshort		0xcc52		RLE image data,
17168349Sobrien>6	leshort		x		%d x
17268349Sobrien>8	leshort		x		%d
17368349Sobrien>2	leshort		>0		\b, lower left corner: %d
17468349Sobrien>4	leshort		>0		\b, lower right corner: %d
17568349Sobrien>10	byte&0x1	=0x1		\b, clear first
17668349Sobrien>10	byte&0x2	=0x2		\b, no background
17768349Sobrien>10	byte&0x4	=0x4		\b, alpha channel
17868349Sobrien>10	byte&0x8	=0x8		\b, comment
17968349Sobrien>11	byte		>0		\b, %d color channels
18068349Sobrien>12	byte		>0		\b, %d bits per pixel
18168349Sobrien>13	byte		>0		\b, %d color map channels
18268349Sobrien
18368349Sobrien# image file format (Robert Potter, potter@cs.rochester.edu)
18468349Sobrien0	string		Imagefile\ version-	iff image data
18568349Sobrien# this adds the whole header (inc. version number), informative but longish
18668349Sobrien>10	string		>\0		%s
18768349Sobrien
18868349Sobrien# Sun raster images, from Daniel Quinlan (quinlan@yggdrasil.com)
18968349Sobrien0	belong		0x59a66a95	Sun raster image data
19068349Sobrien>4	belong		>0		\b, %d x
19168349Sobrien>8	belong		>0		%d,
19268349Sobrien>12	belong		>0		%d-bit,
19368349Sobrien#>16	belong		>0		%d bytes long,
19468349Sobrien>20	belong		0		old format,
19568349Sobrien#>20	belong		1		standard,
19668349Sobrien>20	belong		2		compressed,
19768349Sobrien>20	belong		3		RGB,
19868349Sobrien>20	belong		4		TIFF,
19968349Sobrien>20	belong		5		IFF,
20068349Sobrien>20	belong		0xffff		reserved for testing,
20168349Sobrien>24	belong		0		no colormap
20268349Sobrien>24	belong		1		RGB colormap
20368349Sobrien>24	belong		2		raw colormap
20468349Sobrien#>28	belong		>0		colormap is %d bytes long
20568349Sobrien
20668349Sobrien# SGI image file format, from Daniel Quinlan (quinlan@yggdrasil.com)
20768349Sobrien#
20868349Sobrien# See
20968349Sobrien#	http://reality.sgi.com/grafica/sgiimage.html
21068349Sobrien#
21168349Sobrien0	beshort		474		SGI image data
21268349Sobrien#>2	byte		0		\b, verbatim
21368349Sobrien>2	byte		1		\b, RLE
21468349Sobrien#>3	byte		1		\b, normal precision
21568349Sobrien>3	byte		2		\b, high precision
21668349Sobrien>4	beshort		x		\b, %d-D
21768349Sobrien>6	beshort		x		\b, %d x
21868349Sobrien>8	beshort		x		%d
21968349Sobrien>10	beshort		x		\b, %d channel
22068349Sobrien>10	beshort		!1		\bs
22168349Sobrien>80	string		>0		\b, "%s"
22268349Sobrien
22368349Sobrien0	string		IT01		FIT image data
22468349Sobrien>4	belong		x		\b, %d x
22568349Sobrien>8	belong		x		%d x
22668349Sobrien>12	belong		x		%d
22768349Sobrien#
22868349Sobrien0	string		IT02		FIT image data
22968349Sobrien>4	belong		x		\b, %d x
23068349Sobrien>8	belong		x		%d x
23168349Sobrien>12	belong		x		%d
23268349Sobrien#
23368349Sobrien2048	string		PCD_IPI		Kodak Photo CD image pack file
23468349Sobrien0	string		PCD_OPA		Kodak Photo CD overview pack file
23568349Sobrien
23668349Sobrien# FITS format.  Jeff Uphoff <juphoff@tarsier.cv.nrao.edu>
23768349Sobrien# FITS is the Flexible Image Transport System, the de facto standard for
23868349Sobrien# data and image transfer, storage, etc., for the astronomical community.
23968349Sobrien# (FITS floating point formats are big-endian.)
24068349Sobrien0	string	SIMPLE\ \ =	FITS image data
24168349Sobrien>109	string	8		\b, 8-bit, character or unsigned binary integer
24268349Sobrien>108	string	16		\b, 16-bit, two's complement binary integer
24368349Sobrien>107	string	\ 32		\b, 32-bit, two's complement binary integer
24468349Sobrien>107	string	-32		\b, 32-bit, floating point, single precision
24568349Sobrien>107	string	-64		\b, 64-bit, floating point, double precision
24668349Sobrien
24768349Sobrien# other images
24868349Sobrien0	string	This\ is\ a\ BitMap\ file	Lisp Machine bit-array-file
24968349Sobrien0	string		!!		Bennet Yee's "face" format
25068349Sobrien
25168349Sobrien# From SunOS 5.5.1 "/etc/magic" - appeared right before Sun raster image
25268349Sobrien# stuff.
25368349Sobrien#
25468349Sobrien0	beshort		0x1010		PEX Binary Archive
25568349Sobrien
25668349Sobrien# Visio drawings
25768349Sobrien03000	string	Visio\ (TM)\ Drawing	%s
25868349Sobrien
25968349Sobrien# Tgif files
26068349Sobrien0	string	\%TGIF\ x 		Tgif file version %s
26168349Sobrien
26268349Sobrien# DICOM medical imaging data
26368349Sobrien128	string	DICM			DICOM medical imaging data
26474784Sobrien
26574784Sobrien# XWD - X-Windows Dump file.
26674784Sobrien#   As described in /usr/X11R6/include/X11/XWDFile.h
26774784Sobrien#   used by the xwd program.
26874784Sobrien#   Bradford Castalia, idaeim, 1/01
26974784Sobrien4	belong	7			XWD X-Widows Dump image data
27074784Sobrien>100	string	>\0			\b, "%s"
27174784Sobrien>16	belong	x			\b, %dx
27274784Sobrien>20	belong	x			\b%dx
27374784Sobrien>12	belong	x			\b%d
27474784Sobrien
27574784Sobrien# PDS - Planetary Data System
27674784Sobrien#   These files use Parameter Value Language in the header section.
27774784Sobrien#   Unfortunately, there is no certain magic, but the following
27874784Sobrien#   strings have been found to be most likely.
27974784Sobrien0	string	NJPL1I00		PDS (JPL) image data
28074784Sobrien2	string	NJPL1I			PDS (JPL) image data
28174784Sobrien0	string	CCSD3ZF			PDS (CCSD) image data
28274784Sobrien2	string	CCSD3Z			PDS (CCSD) image data
28374784Sobrien0	string	PDS_			PDS image data
28474784Sobrien0	string	LBLSIZE=		PDS (VICAR) image data
28574784Sobrien
28674784Sobrien0	string		GSTIm		GNU SmallTalk image file
28774784Sobrien
28874784Sobrien# pM8x: ATARI STAD compressed bitmap format
28974784Sobrien#
29074784Sobrien# from Oskar Schirmer <schirmer@scara.com> Feb 2, 2001
29174784Sobrien# p M 8 5/6 xx yy zz data...
29274784Sobrien# Atari ST STAD bitmap is always 640x400, bytewise runlength compressed.
29374784Sobrien# bytes either run horizontally (pM85) or vertically (pM86). yy is the
29474784Sobrien# most frequent byte, xx and zz are runlength escape codes, where xx is
29574784Sobrien# used for runs of yy.
29674784Sobrien#
29774784Sobrien0	string	pM85		Atari ST STAD bitmap image data (hor)
29874784Sobrien>5	byte	0x00		(white background)
29974784Sobrien>5	byte	0xFF		(black background)
30074784Sobrien0	string	pM86		Atari ST STAD bitmap image data (vert)
30174784Sobrien>5	byte	0x00		(white background)
30274784Sobrien>5	byte	0xFF		(black background)
303