1 2#------------------------------------------------------------------------------ 3# images: file(1) magic for image formats (see also "c-lang" for XPM bitmaps) 4# 5# originally from jef@helios.ee.lbl.gov (Jef Poskanzer), 6# additions by janl@ifi.uio.no as well as others. Jan also suggested 7# merging several one- and two-line files into here. 8# 9# XXX - byte order for GIF and TIFF fields? 10# [GRR: TIFF allows both byte orders; GIF is little-endian] 11# 12 13# [GRR: what the hell is this doing in here?] 140 string xbtoa btoa'd file 15 16# PBMPLUS 170 string P1 PBM file 180 string P2 PGM file 190 string P3 PPM file 200 string P4 PBM "rawbits" file 210 string P5 PGM "rawbits" file 220 string P6 PPM "rawbits" file 23 24# NIFF (Navy Interchange File Format, a modification of TIFF) images 25# this *must* go before TIFF 260 string IIN1 NIFF raster data 27 28# TIFF images 290 string MM TIFF file, big-endian 30>2 beshort >0 - version %d 310 string II TIFF file, little-endian 32>2 leshort >0 - version %d 33 34# PNG [Portable Network Graphics, or "PNG's Not GIF"] images 35# (Greg Roelofs, newt@uchicago.edu) 36# 37# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ... 38# 390 string \x89PNG PNG image, 40>4 belong !0x0d0a1a0a CORRUPTED, 41>16 belong x %ld x 42>20 belong x %ld, 43>24 byte x %d-bit 44>25 byte 0 grayscale, 45>25 byte 2 \b/color RGB, 46>25 byte 3 colormap, 47>25 byte 4 gray+alpha, 48>25 byte 6 \b/color RGBA, 49#>26 byte 0 deflate/32K, 50>28 byte 0 non-interlaced 51>28 byte 1 interlaced 52 53# GIF 540 string GIF GIF image 55>3 string 87a - version %s, 56>3 string 89a - version %s, 57>6 leshort >0 %hd x 58>8 leshort >0 %hd, 59#>10 byte &0x80 color mapped, 60# GRR 950330: the following is not accurate for most GIFs: 61#>10 byte &0x40 interlaced, 62>10 byte&0x07 =0x00 2 colors 63>10 byte&0x07 =0x01 4 colors 64>10 byte&0x07 =0x02 8 colors 65>10 byte&0x07 =0x03 16 colors 66>10 byte&0x07 =0x04 32 colors 67>10 byte&0x07 =0x05 64 colors 68>10 byte&0x07 =0x06 128 colors 69>10 byte&0x07 =0x07 256 colors 70 71# Miscellany 720 long 1123028772 Artisan image file 73>4 long 1 rectangular 24-bit image 74>4 long 2 rectangular 8-bit image with colormap 75>4 long 3 rectangular 32-bit image (24-bit with matte) 760 string \361\0\100\273 CMU window manager bitmap 770 string #FIG FIG graphics savefile text 78>6 string 2.1 Version 2.1 79>6 string 2.0 Version 2.0 800 string GKSM GKS Metafile 818 string ILBM IFF ILBM file 820 string ARF_BEGARF PHIGS clear text archive 83 84# More miscellany from Daniel Quinlan (quinlan@yggdrasil.com) 850 string This\ is\ a\ BitMap\ file Lisp Machine bit-array-file 860 string !! Bennet Yee's "face" format 870 string @(#)SunPHIGS SunPHIGS 88# version number follows, in the form m.n 89>40 string SunBin binary 90>32 string archive archive 910 string BEGMF clear text Computer Graphics Metafile 92# these should be beshort, but not sure 930 beshort&0xffe0 0x0020 binary Computer Graphics Metafile 940 beshort 0x3020 character Computer Graphics Metafile 95 96 97# From: <u31b3hs@pool.informatik.rwth-aachen.de> (Michael Haardt) 980 string yz MGR bitmap, modern format, 8 bit aligned 990 string zz MGR bitmap, old format, 1 bit deep, 16 bit aligned 1000 string xz MGR bitmap, old format, 1 bit deep, 32 bit aligned 1010 string yx MGR bitmap, modern format, squeezed 102 1030 string %bitmap FBM pixmap 104>30 long 0x31 (mono) 105>30 long 0x33 (color) 106 1074 string Research, Digifax-G3-File 108>29 byte 1 , fine resolution 109>29 byte 0 , normal resolution 110 111# JPEG images 1120 beshort 0xffd8 JPEG image 113>6 string JFIF - JFIF standard 114# from cameron@cs.unsw.oz.au (Cameron Simpson): 1150 string hsi1 JPEG image - HSI encoded (proprietary) 116 117# PC bitmaps (OS/2, Windoze BMP files) (Greg Roelofs, newt@uchicago.edu) 1180 string BM bitmap 119>14 byte 12 (OS/2 1.x format) 120>14 byte 64 (OS/2 2.x format) 121>14 byte 40 (Windows 3.x format) 1220 string IC icon 1230 string PI pointer 1240 string CI color icon 1250 string CP color pointer 1260 string BA bitmap array 127 128# Utah Raster Toolkit RLE images (two versions) 129# 130# From <janl@ifi.uio.no> 131# I made this with the help of the man page for rle(5). Ihey missing 132# from the magic numbers I have: 1330 beshort 0xcc52 Utah Raster Toolkit RLE 134>2 beshort >0 lower left corner: %d 135>4 beshort >0 lower right corner: %d 136>6 beshort >0 %d x 137>8 beshort >0 %d 138>10 byte&0x1 =0x1 CLEARFIRST 139>10 byte&0x2 =0x2 NO_BACKGROUND 140>10 byte&0x4 =0x4 ALPHA 141>10 byte&0x8 =0x8 COMMENT 142>11 byte >0 %d colour channels 143>12 byte >0 %d bits per pixel 144>13 byte >0 %d colour map channels 145# 146# RLE images (Disaster prone simpleton, m91dps@ecs.ox.ac.uk) 147# Here's a magic file entry for rle images. 24-bit images tend to produce 148# foo.rle size 42x42, 3 comps each 8 bits 149# (for arbitary, prossibly different values of 42). 150# freely redistribuable under the GPL 151# [GRR: which endianness? big?] 1520 short 0xcc55 RLE image data 153>6 short >0 %d x 154>8 short >0 %d, 155>2 short >0 x offset by %d, 156>4 short >0 y offset by %d, 157>11 byte =0 colour map 158>11 byte >1 %d comps each 159>12 byte =1 1 bit 160>12 byte >1 %d bits 161 162# FBM images, culled from xli source (d. p. simpleton, m91dps@ecs.ox.ac.uk) 1630 string %bitmap fbm image data 164 165# image file format (Robert Potter, potter@cs.rochester.edu) 1660 string Imagefile\ version- iff image data 167# this adds the whole header (inc. version number), informative but longish 168>10 string >\0 %s 169 170# Sun rasterfiles, from Daniel Quinlan (quinlan@yggdrasil.com) 171# 172# XXX - Does the Sun 386i use the same byte order? 173# 1740 belong 0x59a66a95 Sun raster image 175>4 belong >0 %d x 176>8 belong >0 %d, 177>12 belong >0 %d-bit, 178# this is almost the same as the file length (what about compressed?) 179#>16 belong >0 %d bytes long, 180>20 belong 0 old format, 181# no need to complain if it is standard 182#>20 belong 1 standard, 183>20 belong 2 compressed, 184>20 belong 3 RGB, 185>20 belong 4 TIFF, 186>20 belong 5 IFF, 187>20 belong 0xffff reserved for testing, 188>24 belong 0 no colormap 189>24 belong 1 RGB colormap 190>24 belong 2 raw colormap 191# this doesn't impart much useful information (or does it?) 192#>28 belong >0 colormap is %d bytes long 193 194# Daniel Quinlan (quinlan@yggdrasil.com) -- from an SGI machine 195# There may be a byte swapped version of SGI imagelib images, but 196# I haven't seen any evidence of programs that support it. 1970 beshort 000732 SGI imagelib image 198>6 beshort x \b, %d x 199>8 beshort x %d 200# 2010 string IT01 FIT image file 202>4 belong x \b, %d x 203>8 belong x %d x 204>12 belong x %d 205# 2060 string IT02 FIT image file 207>4 belong x \b, %d x 208>8 belong x %d x 209>12 belong x %d 210# 2112048 string PCD_IPI Kodak Photo CD image pack file 2120 string PCD_OPA Kodak Photo CD overview pack file 213 214# Jeff Uphoff <juphoff@tarsier.cv.nrao.edu> 215# FITS is the Flexible Image Transport System, the de facto standard for 216# data and image transfer, storage, etc., for the astronomical community. 217# FITS format. 2180 string SIMPLE\ \ = FITS 219>107 string -32 32 bits per pixel, IEEE big endian float 220>107 string \ 32 32 bits per pixel, unsigned integer 221>108 string 16 16 bits per pixel, unsigned integer 222>109 string 8 8 bits per pixel, unsigned integer 223