]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/file/magic/Magdir/images
MFV r336851:
[FreeBSD/FreeBSD.git] / contrib / file / magic / Magdir / images
1
2 #------------------------------------------------------------------------------
3 # $File: images,v 1.131 2018/02/16 15:44:28 christos Exp $
4 # images:  file(1) magic for image formats (see also "iff", and "c-lang" for
5 # XPM bitmaps)
6 #
7 # originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
8 # additions by janl@ifi.uio.no as well as others. Jan also suggested
9 # merging several one- and two-line files into here.
10 #
11 # little magic: PCX (first byte is 0x0a)
12
13 # Targa - matches `povray', `ppmtotga' and `xv' outputs
14 # by Philippe De Muyter <phdm@macqel.be>
15 # URL: http://justsolve.archiveteam.org/wiki/TGA
16 # Reference: http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf
17 # Update: Joerg Jenderek
18 # at 2, byte ImgType must be 1, 2, 3, 9, 10 or 11
19 #       ,32 or 33 (both not observed)
20 # at 1, byte CoMapType must be 1 if ImgType is 1 or 9, 0 otherwise
21 #       or theoretically 2-128 reserved for use by Truevision or 128-255 may be used for developer applications
22 # at 3, leshort Index is 0 for povray, ppmtotga and xv outputs
23 # `xv' recognizes only a subset of the following (RGB with pixelsize = 24)
24 # `tgatoppm' recognizes a superset (Index may be anything)
25 #
26 # test of Color Map Type 0~no 1~color map
27 # and Image Type 1 2 3 9 10 11 32 33
28 # and Color Map Entry Size 0 15 16 24 32
29 0       ubequad&0x00FeC400000000C0      0
30 # skip more garbage like *.iso by looking for positive image type
31 >2      ubyte                   >0
32 # skip some compiled terminfo like xterm+tmux by looking for image type less equal 33
33 >>2     ubyte                   <34
34 # skip arches.3200 , Finder.Root , Slp.1 by looking for low pixel depth 1 8 15 16 24 32
35 >>>16   ubyte                   1
36 >>>>0           use             tga-image
37 >>>16   ubyte                   8
38 >>>>0           use             tga-image
39 >>>16   ubyte                   15
40 >>>>0           use             tga-image
41 >>>16   ubyte                   16
42 >>>>0           use             tga-image
43 >>>16   ubyte                   24
44 >>>>0           use             tga-image
45 >>>16   ubyte                   32
46 >>>>0           use             tga-image
47 #       display tga bitmap image information
48 0       name                            tga-image
49 >2      ubyte           <34             Targa image data
50 !:mime  image/x-tga
51 !:apple ????TPIC
52 # normal extension .tga but some Truevision products used others:
53 # tpic (Apple),icb (Image Capture Board),vda (Video Display Adapter),vst (NuVista),win (UNSURE about that)
54 !:ext   tga/tpic/icb/vda/vst
55 # image type 1 2 3 9 10 11 32 33
56 >2      ubyte&0xF7      1               - Map
57 >2      ubyte&0xF7      2               - RGB
58 # alpha channel
59 >>17    ubyte&0x0F      >0              \bA
60 >2      ubyte&0xF7      3               - Mono
61 # type not found, but by http://www.fileformat.info/format/tga/corion.htm
62 # Compressed color-mapped data, using Huffman, Delta, and runlength encoding
63 >2      ubyte           32              - Color
64 # Compressed color-mapped data, using Huffman, Delta, and RLE. 4-pass quadtree- type process
65 >2      ubyte           33              - Color
66 # Color Map Type 0~no 1~color map
67 >1      ubyte           1               (
68 # first color map entry, 0 normal
69 >>3     uleshort        >0              \b%d-
70 # color map length 0 2 1dh 3bh d9h 100h
71 >>5     uleshort        x               \b%d)
72 # 8~run length encoding bit
73 >2      ubyte&0x08      8               - RLE
74 # gimp can create big pictures!
75 >12     uleshort        >0              %d x
76 >12     uleshort        =0              65536 x
77 # image height. 0 interpreted as 65536
78 >14     uleshort        >0              %d
79 >14     uleshort        =0              65536
80 # Image Pixel depth 1 8 15 16 24 32
81 >16     ubyte           x               x %d
82 # X origin of image. 0 normal
83 >8      uleshort        >0              +%d
84 # Y origin of image. 0 normal; positive for top
85 >10     uleshort        >0              +%d
86 # Image descriptor: bits 3-0 give the alpha channel depth, bits 5-4 give direction
87 >17     ubyte&0x0F      >0              - %d-bit alpha
88 # bits 5-4 give direction. normal bottom left
89 >17     ubyte           &0x20           - top
90 #>17    ubyte           ^0x20           - bottom
91 >17     ubyte           &0x10           - right
92 #>17    ubyte           ^0x10           - left
93 # some info say other bits 6-7 should be zero
94 # but data storage interleave by http://www.fileformat.info/format/tga/corion.htm
95 # 00 - no interleave;01 - even/odd interleave; 10 - four way interleave; 11 - reserved
96 #>17    ubyte&0xC0      0x00            - no interleave
97 >17     ubyte&0xC0      0x40            - interleave
98 >17     ubyte&0xC0      0x80            - four way interleave
99 >17     ubyte&0xC0      0xC0            - reserved
100 # positive length implies identification field
101 >0      ubyte           >0
102 >>18    string          x               "%s"
103 # last 18 bytes of newer tga file footer signature
104 >18     search/4261301/s        TRUEVISION-XFILE.\0
105 # extension area offset if not 0
106 >>&-8           ulelong                 >0
107 # length of the extension area. normal 495 for version 2.0
108 >>>(&-4.l)      uleshort                0x01EF
109 # AuthorName[41]
110 >>>>&0          string                  >\0             - author "%-.40s"
111 # Comment[324]=4 * 80 null terminated
112 >>>>&41         string                  >\0             - comment "%-.80s"
113 # date
114 >>>>&365        ubequad&0xffffFFFFffff0000      !0
115 # Day
116 >>>>>&-6                uleshort                x               %d
117 # Month
118 >>>>>&-8                uleshort                x               \b-%d
119 # Year
120 >>>>>&-4                uleshort                x               \b-%d
121 # time
122 >>>>&371        ubequad&0xffffFFFFffff0000      !0
123 # hour
124 >>>>>&-8                uleshort                x               %d
125 # minutes
126 >>>>>&-6                uleshort                x               \b:%.2d
127 # second
128 >>>>>&-4                uleshort                x               \b:%.2d
129 # JobName[41]
130 >>>>&377                string                  >\0             - job "%-.40s"
131 # JobHour Jobminute Jobsecond
132 >>>>&418        ubequad&0xffffFFFFffff0000      !0
133 >>>>>&-8                uleshort                x               %d
134 >>>>>&-6                uleshort                x               \b:%.2d
135 >>>>>&-4                uleshort                x               \b:%.2d
136 # SoftwareId[41]
137 >>>>&424                string                  >\0             - %-.40s
138 # SoftwareVersionNumber
139 >>>>&424        ubyte                           >0
140 >>>>>&40                uleshort/100            x               %d
141 >>>>>&40                uleshort%100            x               \b.%d
142 # VersionLetter
143 >>>>>&42                ubyte                   >0x20           \b%c
144 # KeyColor
145 >>>>&468                ulelong                 >0              - keycolor 0x%8.8x
146 # Denominator of Pixel ratio. 0~no pixel aspect
147 >>>>&474        uleshort                        >0
148 # Numerator
149 >>>>>&-4                uleshort                >0              - aspect %d
150 >>>>>&-2                uleshort                x               \b/%d
151 # Denominator of Gamma ratio. 0~no Gamma value
152 >>>>&478        uleshort                        >0
153 # Numerator
154 >>>>>&-4                uleshort                >0              - gamma %d
155 >>>>>&-2                uleshort                x               \b/%d
156 # ColorOffset
157 #>>>>&480       ulelong                 x               - col offset 0x%8.8x
158 # StampOffset
159 #>>>>&484       ulelong                 x               - stamp offset 0x%8.8x
160 # ScanOffset
161 #>>>>&488       ulelong                 x               - scan offset 0x%8.8x
162 # AttributesType
163 #>>>>&492       ubyte                   x               - Attributes 0x%x
164 ## EndOfTGA
165
166 # PBMPLUS images
167 # The next byte following the magic is always whitespace.
168 # strength is changed to try these patterns before "x86 boot sector"
169 0       name            netpbm
170 >3      regex/s         =[0-9]{1,50}\ [0-9]{1,50}       Netpbm image data
171 >>&0    regex           =[0-9]{1,50}                    \b, size = %s x
172 >>>&0   regex           =[0-9]{1,50}                    \b %s
173
174 0       search/1        P1
175 >0      regex/4         P1[\040\t\f\r\n]
176 >>0     use             netpbm
177 >>>0    string          x       \b, bitmap
178 !:strength + 45
179 !:mime  image/x-portable-bitmap
180
181 0       search/1        P2
182 >0      regex/4         P2[\040\t\f\r\n]
183 >>0     use             netpbm
184 >>>0    string          x       \b, greymap
185 !:strength + 45
186 !:mime  image/x-portable-greymap
187
188 0       search/1        P3
189 >0      regex/4         P3[\040\t\f\r\n]
190 >>0     use             netpbm
191 >>>0    string          x       \b, pixmap
192 !:strength + 45
193 !:mime  image/x-portable-pixmap
194
195 0       string          P4
196 >0      regex/4         P4[\040\t\f\r\n]
197 >>0     use             netpbm
198 >>>0    string          x       \b, rawbits, bitmap
199 !:strength + 45
200 !:mime  image/x-portable-bitmap
201
202 0       string          P5
203 >0      regex/4         P5[\040\t\f\r\n]
204 >>0     use             netpbm
205 >>>0    string          x       \b, rawbits, greymap
206 !:strength + 45
207 !:mime  image/x-portable-greymap
208
209 0       string          P6
210 >0      regex/4         P6[\040\t\f\r\n]
211 >>0     use             netpbm
212 >>>0    string          x       \b, rawbits, pixmap
213 !:strength + 45
214 !:mime  image/x-portable-pixmap
215
216 0       string          P7              Netpbm PAM image file
217 !:mime  image/x-portable-pixmap
218
219 # From: bryanh@giraffe-data.com (Bryan Henderson)
220 0       string          \117\072        Solitaire Image Recorder format
221 >4      string          \013            MGI Type 11
222 >4      string          \021            MGI Type 17
223 0       string          .MDA            MicroDesign data
224 >21     byte            48              version 2
225 >21     byte            51              version 3
226 0       string          .MDP            MicroDesign page data
227 >21     byte            48              version 2
228 >21     byte            51              version 3
229
230 # NIFF (Navy Interchange File Format, a modification of TIFF) images
231 # [GRR:  this *must* go before TIFF]
232 0       string          IIN1            NIFF image data
233 !:mime  image/x-niff
234
235 # Canon RAW version 1 (CRW) files are a type of Canon Image File Format
236 # (CIFF) file. These are apparently all little-endian.
237 # From: Adam Buchbinder <adam.buchbinder@gmail.com>
238 # URL: http://www.sno.phy.queensu.ca/~phil/exiftool/canon_raw.html
239 0       string          II\x1a\0\0\0HEAPCCDR    Canon CIFF raw image data
240 !:mime  image/x-canon-crw
241 >16     leshort         x       \b, version %d.
242 >14     leshort         x       \b%d
243
244 # Canon RAW version 2 (CR2) files are a kind of TIFF with an extra magic
245 # number. Put this above the TIFF test to make sure we detect them.
246 # These are apparently all little-endian.
247 # From: Adam Buchbinder <adam.buchbinder@gmail.com>
248 # URL: http://libopenraw.freedesktop.org/wiki/Canon_CR2
249 0       string          II\x2a\0\x10\0\0\0CR    Canon CR2 raw image data
250 !:mime  image/x-canon-cr2
251 >10     byte            x       \b, version %d.
252 >11     byte            x       \b%d
253
254 # Tag Image File Format, from Daniel Quinlan (quinlan@yggdrasil.com)
255 # The second word of TIFF files is the TIFF version number, 42, which has
256 # never changed.  The TIFF specification recommends testing for it.
257 0       string          MM\x00\x2a      TIFF image data, big-endian
258 !:mime  image/tiff
259 >(4.L)  use             \^tiff_ifd
260 0       string          II\x2a\x00      TIFF image data, little-endian
261 !:mime  image/tiff
262 >(4.l)  use             tiff_ifd
263
264 0       name            tiff_ifd
265 >0      leshort         x               \b, direntries=%d
266 >2      use             tiff_entry
267
268 0       name            tiff_entry
269 # NewSubFileType
270 >0      leshort         0xfe
271 >>12    use             tiff_entry
272 >0      leshort         0x100
273 >>4     lelong          1
274 >>>12   use             tiff_entry
275 >>>8    leshort         x               \b, width=%d
276 >0      leshort         0x101
277 >>4     lelong          1
278 >>>8    leshort         x               \b, height=%d
279 >>>12   use             tiff_entry
280 >0      leshort         0x102
281 >>8     leshort         x               \b, bps=%d
282 >>12    use             tiff_entry
283 >0      leshort         0x103
284 >>4     lelong          1               \b, compression=
285 >>>8    leshort         1               \bnone
286 >>>8    leshort         2               \bhuffman
287 >>>8    leshort         3               \bbi-level group 3
288 >>>8    leshort         4               \bbi-level group 4
289 >>>8    leshort         5               \bLZW
290 >>>8    leshort         6               \bJPEG (old)
291 >>>8    leshort         7               \bJPEG
292 >>>8    leshort         8               \bdeflate
293 >>>8    leshort         9               \bJBIG, ITU-T T.85
294 >>>8    leshort         0xa             \bJBIG, ITU-T T.43
295 >>>8    leshort         0x7ffe          \bNeXT RLE 2-bit
296 >>>8    leshort         0x8005          \bPackBits (Macintosh RLE)
297 >>>8    leshort         0x8029          \bThunderscan RLE
298 >>>8    leshort         0x807f          \bRasterPadding (CT or MP)
299 >>>8    leshort         0x8080          \bRLE (Line Work)
300 >>>8    leshort         0x8081          \bRLE (High-Res Cont-Tone)
301 >>>8    leshort         0x8082          \bRLE (Binary Line Work)
302 >>>8    leshort         0x80b2          \bDeflate (PKZIP)
303 >>>8    leshort         0x80b3          \bKodak DCS
304 >>>8    leshort         0x8765          \bJBIG
305 >>>8    leshort         0x8798          \bJPEG2000
306 >>>8    leshort         0x8799          \bNikon NEF Compressed
307 >>>8    default         x
308 >>>>8   leshort         x               \b(unknown 0x%x)
309 >>>12   use             tiff_entry
310 >0      leshort         0x106           \b, PhotometricIntepretation=
311 >>8     clear           x
312 >>8     leshort         0               \bWhiteIsZero
313 >>8     leshort         1               \bBlackIsZero
314 >>8     leshort         2               \bRGB
315 >>8     leshort         3               \bRGB Palette
316 >>8     leshort         4               \bTransparency Mask
317 >>8     leshort         5               \bCMYK
318 >>8     leshort         6               \bYCbCr
319 >>8     leshort         8               \bCIELab
320 >>8     default         x
321 >>>8    leshort         x               \b(unknown=0x%x)
322 >>12    use             tiff_entry
323 # FillOrder
324 >0      leshort         0x10a
325 >>4     lelong          1
326 >>>12   use             tiff_entry
327 # DocumentName
328 >0      leshort         0x10d
329 >>(8.l) string          x               \b, name=%s
330 >>>12   use             tiff_entry
331 # ImageDescription
332 >0      leshort         0x10e
333 >>(8.l) string          x               \b, description=%s
334 >>>12   use             tiff_entry
335 # Make
336 >0      leshort         0x10f
337 >>(8.l) string          x               \b, manufacturer=%s
338 >>>12   use             tiff_entry
339 # Model
340 >0      leshort         0x110
341 >>(8.l) string          x               \b, model=%s
342 >>>12   use             tiff_entry
343 # StripOffsets
344 >0      leshort         0x111
345 >>12    use             tiff_entry
346 # Orientation
347 >0      leshort         0x112           \b, orientation=
348 >>8     leshort         1               \bupper-left
349 >>8     leshort         3               \blower-right
350 >>8     leshort         6               \bupper-right
351 >>8     leshort         8               \blower-left
352 >>8     leshort         9               \bundefined
353 >>8     default         x
354 >>>8    leshort         x               \b[*%d*]
355 >>12    use             tiff_entry
356 # XResolution
357 >0      leshort         0x11a
358 >>8     lelong          x               \b, xresolution=%d
359 >>12    use             tiff_entry
360 # YResolution
361 >0      leshort         0x11b
362 >>8     lelong          x               \b, yresolution=%d
363 >>12    use             tiff_entry
364 # ResolutionUnit
365 >0      leshort         0x128
366 >>8     leshort         x               \b, resolutionunit=%d
367 >>12    use             tiff_entry
368 # Software
369 >0      leshort         0x131
370 >>(8.l) string          x               \b, software=%s
371 >>12    use             tiff_entry
372 # Datetime
373 >0      leshort         0x132
374 >>(8.l) string          x               \b, datetime=%s
375 >>12    use             tiff_entry
376 # HostComputer
377 >0      leshort         0x13c
378 >>(8.l) string          x               \b, hostcomputer=%s
379 >>12    use             tiff_entry
380 # WhitePoint
381 >0      leshort         0x13e
382 >>12    use             tiff_entry
383 # PrimaryChromaticities
384 >0      leshort         0x13f
385 >>12    use             tiff_entry
386 # YCbCrCoefficients
387 >0      leshort         0x211
388 >>12    use             tiff_entry
389 # YCbCrPositioning
390 >0      leshort         0x213
391 >>12    use             tiff_entry
392 # ReferenceBlackWhite
393 >0      leshort         0x214
394 >>12    use             tiff_entry
395 # Copyright
396 >0      leshort         0x8298
397 >>(8.l) string          x               \b, copyright=%s
398 >>12    use             tiff_entry
399 # ExifOffset
400 >0      leshort         0x8769
401 >>12    use             tiff_entry
402 # GPS IFD
403 >0      leshort         0x8825          \b, GPS-Data
404 >>12    use             tiff_entry
405
406 #>0     leshort         x               \b, unknown=0x%x
407 #>>12   use             tiff_entry
408
409 0       string          MM\x00\x2b      Big TIFF image data, big-endian
410 !:mime  image/tiff
411 0       string          II\x2b\x00      Big TIFF image data, little-endian
412 !:mime  image/tiff
413
414 # PNG [Portable Network Graphics, or "PNG's Not GIF"] images
415 # (Greg Roelofs, newt@uchicago.edu)
416 # (Albert Cahalan, acahalan@cs.uml.edu)
417 #
418 # 137 P N G \r \n ^Z \n [4-byte length] I H D R [HEAD data] [HEAD crc] ...
419 #
420
421 # IHDR parser
422 0       name            png-ihdr
423 >0      belong          x               \b, %d x
424 >4      belong          x               %d,
425 >8      byte            x               %d-bit
426 >9      byte            0               grayscale,
427 >9      byte            2               \b/color RGB,
428 >9      byte            3               colormap,
429 >9      byte            4               gray+alpha,
430 >9      byte            6               \b/color RGBA,
431 #>10    byte            0               deflate/32K,
432 >12     byte            0               non-interlaced
433 >12     byte            1               interlaced
434
435 # Standard PNG image.
436 0       string          \x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0DIHDR     PNG image data
437 !:mime  image/png
438 !:strength +10
439 >16     use             png-ihdr
440
441 # Apple CgBI PNG image.
442 0       string          \x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x04CgBI
443 >24     string          \x00\x00\x00\x0DIHDR    PNG image data (CgBI)
444 !:mime  image/png
445 !:strength +10
446 >>32    use             png-ihdr
447
448 # possible GIF replacements; none yet released!
449 # (Greg Roelofs, newt@uchicago.edu)
450 #
451 # GRR 950115:  this was mine ("Zip GIF"):
452 0       string          GIF94z          ZIF image (GIF+deflate alpha)
453 !:mime  image/x-unknown
454 #
455 # GRR 950115:  this is Jeremy Wohl's Free Graphics Format (better):
456 #
457 0       string          FGF95a          FGF image (GIF+deflate beta)
458 !:mime  image/x-unknown
459 #
460 # GRR 950115:  this is Thomas Boutell's Portable Bitmap Format proposal
461 # (best; not yet implemented):
462 #
463 0       string          PBF             PBF image (deflate compression)
464 !:mime  image/x-unknown
465
466 # GIF
467 0       string          GIF8            GIF image data
468 !:mime  image/gif
469 !:apple 8BIMGIFf
470 >4      string          7a              \b, version 8%s,
471 >4      string          9a              \b, version 8%s,
472 >6      leshort         >0              %d x
473 >8      leshort         >0              %d
474 #>10    byte            &0x80           color mapped,
475 #>10    byte&0x07       =0x00           2 colors
476 #>10    byte&0x07       =0x01           4 colors
477 #>10    byte&0x07       =0x02           8 colors
478 #>10    byte&0x07       =0x03           16 colors
479 #>10    byte&0x07       =0x04           32 colors
480 #>10    byte&0x07       =0x05           64 colors
481 #>10    byte&0x07       =0x06           128 colors
482 #>10    byte&0x07       =0x07           256 colors
483
484 # ITC (CMU WM) raster files.  It is essentially a byte-reversed Sun raster,
485 # 1 plane, no encoding.
486 0       string          \361\0\100\273  CMU window manager raster image data
487 >4      lelong          >0              %d x
488 >8      lelong          >0              %d,
489 >12     lelong          >0              %d-bit
490
491 # Magick Image File Format
492 0       string          id=ImageMagick  MIFF image data
493
494 # Artisan
495 0       long            1123028772      Artisan image data
496 >4      long            1               \b, rectangular 24-bit
497 >4      long            2               \b, rectangular 8-bit with colormap
498 >4      long            3               \b, rectangular 32-bit (24-bit with matte)
499
500 # FIG (Facility for Interactive Generation of figures), an object-based format
501 0       search/1        #FIG            FIG image text
502 >5      string          x               \b, version %.3s
503
504 # PHIGS
505 0       string          ARF_BEGARF              PHIGS clear text archive
506 0       string          @(#)SunPHIGS            SunPHIGS
507 # version number follows, in the form m.n
508 >40     string          SunBin                  binary
509 >32     string          archive                 archive
510
511 # GKS (Graphics Kernel System)
512 0       string          GKSM            GKS Metafile
513 >24     string          SunGKS          \b, SunGKS
514
515 # CGM image files
516 0       string          BEGMF           clear text Computer Graphics Metafile
517
518 # MGR bitmaps  (Michael Haardt, u31b3hs@pool.informatik.rwth-aachen.de)
519 0       string  yz      MGR bitmap, modern format, 8-bit aligned
520 0       string  zz      MGR bitmap, old format, 1-bit deep, 16-bit aligned
521 0       string  xz      MGR bitmap, old format, 1-bit deep, 32-bit aligned
522 0       string  yx      MGR bitmap, modern format, squeezed
523
524 # Fuzzy Bitmap (FBM) images
525 0       string          %bitmap\0       FBM image data
526 >30     long            0x31            \b, mono
527 >30     long            0x33            \b, color
528
529 # facsimile data
530 1       string          PC\ Research,\ Inc      group 3 fax data
531 >29     byte            0               \b, normal resolution (204x98 DPI)
532 >29     byte            1               \b, fine resolution (204x196 DPI)
533 # From: Herbert Rosmanith <herp@wildsau.idv.uni.linz.at>
534 0       string          Sfff            structured fax file
535
536 # From: Joerg Jenderek <joerg.jen.der.ek@gmx.net>
537 # most files with the extension .EPA and some with .BMP
538 0       string          \x11\x06        Award BIOS Logo, 136 x 84
539 !:mime  image/x-award-bioslogo
540 0       string          \x11\x09        Award BIOS Logo, 136 x 126
541 !:mime  image/x-award-bioslogo
542 #0      string          \x07\x1f        BIOS Logo corrupted?
543 # http://www.blackfiveservices.co.uk/awbmtools.shtml
544 # http://biosgfx.narod.ru/v3/
545 # http://biosgfx.narod.ru/abr-2/
546 0       string          AWBM
547 >4      leshort         <1981           Award BIOS bitmap
548 !:mime  image/x-award-bmp
549 # image width is a multiple of 4
550 >>4     leshort&0x0003  0
551 >>>4            leshort x               \b, %d
552 >>>6            leshort x               x %d
553 >>4     leshort&0x0003  >0              \b,
554 >>>4    leshort&0x0003  =1
555 >>>>4           leshort x               %d+3
556 >>>4    leshort&0x0003  =2
557 >>>>4           leshort x               %d+2
558 >>>4    leshort&0x0003  =3
559 >>>>4           leshort x               %d+1
560 >>>6            leshort x               x %d
561 # at offset 8 starts imagedata followed by "RGB " marker
562
563 # PC bitmaps (OS/2, Windows BMP files)  (Greg Roelofs, newt@uchicago.edu)
564 # http://en.wikipedia.org/wiki/BMP_file_format#DIB_header_.\
565 # 28bitmap_information_header.29
566 0       string          BM
567 >14     leshort         12              PC bitmap, OS/2 1.x format
568 !:mime  image/x-ms-bmp
569 >>18    leshort         x               \b, %d x
570 >>20    leshort         x               %d
571 >14     leshort         64              PC bitmap, OS/2 2.x format
572 !:mime  image/x-ms-bmp
573 >>18    leshort         x               \b, %d x
574 >>20    leshort         x               %d
575 >14     leshort         40              PC bitmap, Windows 3.x format
576 !:mime  image/x-ms-bmp
577 >>18    lelong          x               \b, %d x
578 >>22    lelong          x               %d x
579 >>28    leshort         x               %d
580 >14     leshort         124             PC bitmap, Windows 98/2000 and newer format
581 !:mime  image/x-ms-bmp
582 >>18    lelong          x               \b, %d x
583 >>22    lelong          x               %d x
584 >>28    leshort         x               %d
585 >14     leshort         108             PC bitmap, Windows 95/NT4 and newer format
586 !:mime  image/x-ms-bmp
587 >>18    lelong          x               \b, %d x
588 >>22    lelong          x               %d x
589 >>28    leshort         x               %d
590 >14     leshort         128             PC bitmap, Windows NT/2000 format
591 !:mime  image/x-ms-bmp
592 >>18    lelong          x               \b, %d x
593 >>22    lelong          x               %d x
594 >>28    leshort         x               %d
595 # Too simple - MPi
596 #0      string          IC              PC icon data
597 #0      string          PI              PC pointer image data
598 #0      string          CI              PC color icon data
599 #0      string          CP              PC color pointer image data
600 # Conflicts with other entries [BABYL]
601 #0      string          BA              PC bitmap array data
602
603 # XPM icons (Greg Roelofs, newt@uchicago.edu)
604 0       search/1        /*\ XPM\ */     X pixmap image text
605 !:mime  image/x-xpmi
606
607 # Utah Raster Toolkit RLE images (janl@ifi.uio.no)
608 0       leshort         0xcc52          RLE image data,
609 >6      leshort         x               %d x
610 >8      leshort         x               %d
611 >2      leshort         >0              \b, lower left corner: %d
612 >4      leshort         >0              \b, lower right corner: %d
613 >10     byte&0x1        =0x1            \b, clear first
614 >10     byte&0x2        =0x2            \b, no background
615 >10     byte&0x4        =0x4            \b, alpha channel
616 >10     byte&0x8        =0x8            \b, comment
617 >11     byte            >0              \b, %d color channels
618 >12     byte            >0              \b, %d bits per pixel
619 >13     byte            >0              \b, %d color map channels
620
621 # image file format (Robert Potter, potter@cs.rochester.edu)
622 0       string          Imagefile\ version-     iff image data
623 # this adds the whole header (inc. version number), informative but longish
624 >10     string          >\0             %s
625
626 # Sun raster images, from Daniel Quinlan (quinlan@yggdrasil.com)
627 0       belong          0x59a66a95      Sun raster image data
628 >4      belong          >0              \b, %d x
629 >8      belong          >0              %d,
630 >12     belong          >0              %d-bit,
631 #>16    belong          >0              %d bytes long,
632 >20     belong          0               old format,
633 #>20    belong          1               standard,
634 >20     belong          2               compressed,
635 >20     belong          3               RGB,
636 >20     belong          4               TIFF,
637 >20     belong          5               IFF,
638 >20     belong          0xffff          reserved for testing,
639 >24     belong          0               no colormap
640 >24     belong          1               RGB colormap
641 >24     belong          2               raw colormap
642 #>28    belong          >0              colormap is %d bytes long
643
644 # SGI image file format, from Daniel Quinlan (quinlan@yggdrasil.com)
645 #
646 # See
647 #       http://reality.sgi.com/grafica/sgiimage.html
648 #
649 0       beshort         474             SGI image data
650 #>2     byte            0               \b, verbatim
651 >2      byte            1               \b, RLE
652 #>3     byte            1               \b, normal precision
653 >3      byte            2               \b, high precision
654 >4      beshort         x               \b, %d-D
655 >6      beshort         x               \b, %d x
656 >8      beshort         x               %d
657 >10     beshort         x               \b, %d channel
658 >10     beshort         !1              \bs
659 >80     string          >0              \b, "%s"
660
661 0       string          IT01            FIT image data
662 >4      belong          x               \b, %d x
663 >8      belong          x               %d x
664 >12     belong          x               %d
665 #
666 0       string          IT02            FIT image data
667 >4      belong          x               \b, %d x
668 >8      belong          x               %d x
669 >12     belong          x               %d
670 #
671 2048    string          PCD_IPI         Kodak Photo CD image pack file
672 >0xe02  byte&0x03       0x00            , landscape mode
673 >0xe02  byte&0x03       0x01            , portrait mode
674 >0xe02  byte&0x03       0x02            , landscape mode
675 >0xe02  byte&0x03       0x03            , portrait mode
676 0       string          PCD_OPA         Kodak Photo CD overview pack file
677
678 # FITS format.  Jeff Uphoff <juphoff@tarsier.cv.nrao.edu>
679 # FITS is the Flexible Image Transport System, the de facto standard for
680 # data and image transfer, storage, etc., for the astronomical community.
681 # (FITS floating point formats are big-endian.)
682 0       string  SIMPLE\ \ =     FITS image data
683 >109    string  8               \b, 8-bit, character or unsigned binary integer
684 >108    string  16              \b, 16-bit, two's complement binary integer
685 >107    string  \ 32            \b, 32-bit, two's complement binary integer
686 >107    string  -32             \b, 32-bit, floating point, single precision
687 >107    string  -64             \b, 64-bit, floating point, double precision
688
689 # other images
690 0       string  This\ is\ a\ BitMap\ file       Lisp Machine bit-array-file
691
692 # From SunOS 5.5.1 "/etc/magic" - appeared right before Sun raster image
693 # stuff.
694 #
695 0       beshort         0x1010          PEX Binary Archive
696
697 # DICOM medical imaging data
698 # URL:          https://en.wikipedia.org/wiki/DICOM#Data_format
699 # Note:         "dcm" is the official file name extension
700 #               XnView mention also "dc3" and "acr" as file name extension
701 128     string  DICM                    DICOM medical imaging data
702 !:mime  application/dicom
703 !:ext dcm/dicom/dic
704
705 # XWD - X Window Dump file.
706 #   As described in /usr/X11R6/include/X11/XWDFile.h
707 #   used by the xwd program.
708 #   Bradford Castalia, idaeim, 1/01
709 #   updated by Adam Buchbinder, 2/09
710 # The following assumes version 7 of the format; the first long is the length
711 # of the header, which is at least 25 4-byte longs, and the one at offset 8
712 # is a constant which is always either 1 or 2. Offset 12 is the pixmap depth,
713 # which is a maximum of 32.
714 0       belong  >100
715 >8      belong  <3
716 >>12    belong  <33
717 >>>4    belong  7                       XWD X Window Dump image data
718 !:mime  image/x-xwindowdump
719 >>>>100 string  >\0                     \b, "%s"
720 >>>>16  belong  x                       \b, %dx
721 >>>>20  belong  x                       \b%dx
722 >>>>12  belong  x                       \b%d
723
724 # PDS - Planetary Data System
725 #   These files use Parameter Value Language in the header section.
726 #   Unfortunately, there is no certain magic, but the following
727 #   strings have been found to be most likely.
728 0       string  NJPL1I00                PDS (JPL) image data
729 2       string  NJPL1I                  PDS (JPL) image data
730 0       string  CCSD3ZF                 PDS (CCSD) image data
731 2       string  CCSD3Z                  PDS (CCSD) image data
732 0       string  PDS_                    PDS image data
733 0       string  LBLSIZE=                PDS (VICAR) image data
734
735 # pM8x: ATARI STAD compressed bitmap format
736 #
737 # from Oskar Schirmer <schirmer@scara.com> Feb 2, 2001
738 # p M 8 5/6 xx yy zz data...
739 # Atari ST STAD bitmap is always 640x400, bytewise runlength compressed.
740 # bytes either run horizontally (pM85) or vertically (pM86). yy is the
741 # most frequent byte, xx and zz are runlength escape codes, where xx is
742 # used for runs of yy.
743 #
744 0       string  pM85            Atari ST STAD bitmap image data (hor)
745 >5      byte    0x00            (white background)
746 >5      byte    0xFF            (black background)
747 0       string  pM86            Atari ST STAD bitmap image data (vert)
748 >5      byte    0x00            (white background)
749 >5      byte    0xFF            (black background)
750
751 # From: Alex Myczko <alex@aiei.ch>
752 # http://www.atarimax.com/jindroush.atari.org/afmtatr.html
753 0       leshort 0x0296          Atari ATR image
754
755 # XXX:
756 # This is bad magic 0x5249 == 'RI' conflicts with RIFF and other
757 # magic.
758 # SGI RICE image file <mpruett@sgi.com>
759 #0      beshort 0x5249          RICE image
760 #>2     beshort x               v%d
761 #>4     beshort x               (%d x
762 #>6     beshort x               %d)
763 #>8     beshort 0               8 bit
764 #>8     beshort 1               10 bit
765 #>8     beshort 2               12 bit
766 #>8     beshort 3               13 bit
767 #>10    beshort 0               4:2:2
768 #>10    beshort 1               4:2:2:4
769 #>10    beshort 2               4:4:4
770 #>10    beshort 3               4:4:4:4
771 #>12    beshort 1               RGB
772 #>12    beshort 2               CCIR601
773 #>12    beshort 3               RP175
774 #>12    beshort 4               YUV
775
776 # PCX image files
777 # From: Dan Fandrich <dan@coneharvesters.com>
778 # updated by Joerg Jenderek at Feb 2013 by http://de.wikipedia.org/wiki/PCX
779 # http://web.archive.org/web/20100206055706/http://www.qzx.com/pc-gpe/pcx.txt
780 # GRR: original test was still too general as it catches xbase examples T5.DBT,T6.DBT with 0xa000000
781 # test for bytes 0x0a,version byte (0,2,3,4,5),compression byte flag(0,1), bit depth (>0) of PCX or T5.DBT,T6.DBT
782 0       ubelong&0xffF8fe00      0x0a000000
783 # for PCX bit depth > 0
784 >3      ubyte           >0
785 # test for valid versions
786 >>1     ubyte           <6
787 >>>1    ubyte           !1      PCX
788 !:mime  image/x-pcx
789 #!:mime image/pcx
790 >>>>1   ubyte           0       ver. 2.5 image data
791 >>>>1   ubyte           2       ver. 2.8 image data, with palette
792 >>>>1   ubyte           3       ver. 2.8 image data, without palette
793 >>>>1   ubyte           4       for Windows image data
794 >>>>1   ubyte           5       ver. 3.0 image data
795 >>>>4   uleshort        x       bounding box [%d,
796 >>>>6   uleshort        x       %d] -
797 >>>>8   uleshort        x       [%d,
798 >>>>10  uleshort        x       %d],
799 >>>>65  ubyte           >1      %d planes each of
800 >>>>3   ubyte           x       %d-bit
801 >>>>68  byte            1       colour,
802 >>>>68  byte            2       grayscale,
803 # this should not happen
804 >>>>68  default         x       image,
805 >>>>12  leshort         >0      %d x
806 >>>>>14 uleshort        x       %d dpi,
807 >>>>2   byte            0       uncompressed
808 >>>>2   byte            1       RLE compressed
809
810 # Adobe Photoshop
811 # From: Asbjoern Sloth Toennesen <asbjorn@lila.io>
812 0       string          8BPS Adobe Photoshop Image
813 !:mime  image/vnd.adobe.photoshop
814 >4   beshort 2 (PSB)
815 >18  belong  x \b, %d x
816 >14  belong  x %d,
817 >24  beshort 0 bitmap
818 >24  beshort 1 grayscale
819 >>12 beshort 2 with alpha
820 >24  beshort 2 indexed
821 >24  beshort 3 RGB
822 >>12 beshort 4 \bA
823 >24  beshort 4 CMYK
824 >>12 beshort 5 \bA
825 >24  beshort 7 multichannel
826 >24  beshort 8 duotone
827 >24  beshort 9 lab
828 >12  beshort > 1
829 >>12  beshort x \b, %dx
830 >12  beshort 1 \b,
831 >22  beshort x %d-bit channel
832 >12  beshort > 1 \bs
833
834 # XV thumbnail indicator (ThMO)
835 0       string          P7\ 332         XV thumbnail image data
836
837 # NITF is defined by United States MIL-STD-2500A
838 0       string  NITF    National Imagery Transmission Format
839 >25     string  >\0     dated %.14s
840
841 # GEM Image: Version 1, Headerlen 8 (Wolfram Kleff)
842 # Format variations from: Bernd Nuernberger <bernd.nuernberger@web.de>
843 # Update: Joerg Jenderek
844 # See http://fileformats.archiveteam.org/wiki/GEM_Raster
845 # For variations, also see:
846 #    http://www.seasip.info/Gem/ff_img.html (Ventura)
847 #    http://www.atari-wiki.com/?title=IMG_file (XIMG, STTT)
848 #    http://www.fileformat.info/format/gemraster/spec/index.htm (XIMG, STTT)
849 #    http://sylvana.net/1stguide/1STGUIDE.ENG (TIMG)
850 0       beshort     0x0001
851 # header_size
852 >2      beshort     0x0008
853 >>0     use gem_info
854 >2      beshort     0x0009
855 >>0     use gem_info
856 # no example for NOSIG
857 >2      beshort     24
858 >>0     use gem_info
859 # no example for HYPERPAINT
860 >2      beshort     25
861 >>0     use gem_info
862 16      string      XIMG\0
863 >0      use gem_info
864 # no example
865 16      string      STTT\0\x10
866 >0      use gem_info
867 # no example or description
868 16      string      TIMG\0
869 >0      use gem_info
870
871 0   name        gem_info
872 # version is 2 for some XIMG and 1 for all others
873 >0      beshort         <0x0003         GEM
874 # http://www.snowstone.org.uk/riscos/mimeman/mimemap.txt
875 !:mime  image/x-gem
876 # header_size 24 25 27 59 779 words for colored bitmaps
877 >>2     beshort         >9
878 >>>16   string          STTT\0\x10      STTT
879 >>>16   string          TIMG\0          TIMG
880 # HYPERPAINT or NOSIG variant
881 >>>16   string          \0\x80
882 >>>>2   beshort         =24             NOSIG
883 >>>>2   beshort         !24             HYPERPAINT
884 # NOSIG or XIMG variant
885 >>>16   default         x
886 >>>>16  string          !XIMG\0         NOSIG
887 >>16    string          =XIMG\0         XIMG Image data
888 !:ext   img/ximg
889 # to avoid Warning: Current entry does not yet have a description for adding a EXTENSION type
890 >>16    string          !XIMG\0         Image data
891 !:ext   img
892 # header_size is 9 for Ventura files and 8 for other GEM Paint files
893 >>2     beshort         9               (Ventura)
894 #>>2    beshort         8               (Paint)
895 >>12    beshort         x               %d x
896 >>14    beshort         x               %d,
897 # 1 4 8
898 >>4     beshort         x               %d planes,
899 # in tenths of a millimetre
900 >>8     beshort         x               %d x
901 >>10    beshort         x               %d pixelsize
902 # pattern_size 1-8. 2 for GEM Paint
903 >>6     beshort         !2              \b, pattern size %d
904
905 # GEM Metafile (Wolfram Kleff)
906 0       lelong          0x0018FFFF      GEM Metafile data
907 >4      leshort         x               version %d
908
909 #
910 # SMJPEG. A custom Motion JPEG format used by Loki Entertainment
911 # Software Torbjorn Andersson <d91tan@Update.UU.SE>.
912 #
913 0       string  \0\nSMJPEG      SMJPEG
914 >8      belong  x               %d.x data
915 # According to the specification you could find any number of _TXT
916 # headers here, but I can't think of any way of handling that. None of
917 # the SMJPEG files I tried it on used this feature. Even if such a
918 # file is encountered the output should still be reasonable.
919 >16     string  _SND            \b,
920 >>24    beshort >0              %d Hz
921 >>26    byte    8               8-bit
922 >>26    byte    16              16-bit
923 >>28    string  NONE            uncompressed
924 # >>28  string  APCM            ADPCM compressed
925 >>27    byte    1               mono
926 >>28    byte    2               stereo
927 # Help! Isn't there any way to avoid writing this part twice?
928 >>32    string  _VID            \b,
929 # >>>48 string  JFIF            JPEG
930 >>>40   belong  >0              %d frames
931 >>>44   beshort >0              (%d x
932 >>>46   beshort >0              %d)
933 >16     string  _VID            \b,
934 # >>32  string  JFIF            JPEG
935 >>24    belong  >0              %d frames
936 >>28    beshort >0              (%d x
937 >>30    beshort >0              %d)
938
939 0       string  Paint\ Shop\ Pro\ Image\ File   Paint Shop Pro Image File
940
941 # "thumbnail file" (icon)
942 # descended from "xv", but in use by other applications as well (Wolfram Kleff)
943 0       string          P7\ 332         XV "thumbnail file" (icon) data
944
945 # taken from fkiss: (<yav@mte.biglobe.ne.jp> ?)
946 0       string          KiSS            KISS/GS
947 >4      byte            16              color
948 >>5     byte            x               %d bit
949 >>8     leshort         x               %d colors
950 >>10    leshort         x               %d groups
951 >4      byte            32              cell
952 >>5     byte            x               %d bit
953 >>8     leshort         x               %d x
954 >>10    leshort         x               %d
955 >>12    leshort         x               +%d
956 >>14    leshort         x               +%d
957
958 # Webshots (www.webshots.com), by John Harrison
959 0       string          C\253\221g\230\0\0\0 Webshots Desktop .wbz file
960
961 # Hercules DASD image files
962 # From Jan Jaeger <jj@septa.nl>
963 0       string  CKD_P370        Hercules CKD DASD image file
964 >8      long    x               \b, %d heads per cylinder
965 >12     long    x               \b, track size %d bytes
966 >16     byte    x               \b, device type 33%2.2X
967
968 0       string  CKD_C370        Hercules compressed CKD DASD image file
969 >8      long    x               \b, %d heads per cylinder
970 >12     long    x               \b, track size %d bytes
971 >16     byte    x               \b, device type 33%2.2X
972
973 0       string  CKD_S370        Hercules CKD DASD shadow file
974 >8      long    x               \b, %d heads per cylinder
975 >12     long    x               \b, track size %d bytes
976 >16     byte    x               \b, device type 33%2.2X
977
978 # Squeak images and programs - etoffi@softhome.net
979 0       string          \146\031\0\0    Squeak image data
980 0       search/1        'From\040Squeak Squeak program text
981
982 # partimage: file(1) magic for PartImage files (experimental, incomplete)
983 # Author: Hans-Joachim Baader <hjb@pro-linux.de>
984 0               string  PaRtImAgE-VoLuMe        PartImage
985 >0x0020         string  0.6.1           file version %s
986 >>0x0060        lelong  >-1             volume %d
987 #>>0x0064 8 byte identifier
988 #>>0x007c reserved
989 >>0x0200        string  >\0             type %s
990 >>0x1400        string  >\0             device %s,
991 >>0x1600        string  >\0             original filename %s,
992 # Some fields omitted
993 >>0x2744        lelong  0               not compressed
994 >>0x2744        lelong  1               gzip compressed
995 >>0x2744        lelong  2               bzip2 compressed
996 >>0x2744        lelong  >2              compressed with unknown algorithm
997 >0x0020         string  >0.6.1          file version %s
998 >0x0020         string  <0.6.1          file version %s
999
1000 # DCX is multi-page PCX, using a simple header of up to 1024
1001 # offsets for the respective PCX components.
1002 # From: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
1003 0       lelong  987654321       DCX multi-page PCX image data
1004
1005 # Simon Walton <simonw@matteworld.com>
1006 # Kodak Cineon format for scanned negatives
1007 # http://www.kodak.com/US/en/motion/support/dlad/
1008 0       lelong  0xd75f2a80      Cineon image data
1009 >200    belong  >0              \b, %d x
1010 >204    belong  >0              %d
1011
1012
1013 # Bio-Rad .PIC is an image format used by microscope control systems
1014 # and related image processing software used by biologists.
1015 # From: Vebjorn Ljosa <vebjorn@ljosa.com>
1016 # BOOL values are two-byte integers; use them to rule out false positives.
1017 # http://web.archive.org/web/20050317223257/www.cs.ubc.ca/spider/ladic/text/biorad.txt
1018 # Samples: http://www.loci.wisc.edu/software/sample-data
1019 14      leshort <2
1020 >62     leshort <2
1021 >>54    leshort 12345           Bio-Rad .PIC Image File
1022 >>>0    leshort >0              %d x
1023 >>>2    leshort >0              %d,
1024 >>>4    leshort =1              1 image in file
1025 >>>4    leshort >1              %d images in file
1026
1027 # From Jan "Yenya" Kasprzak <kas@fi.muni.cz>
1028 # The description of *.mrw format can be found at
1029 # http://www.dalibor.cz/minolta/raw_file_format.htm
1030 0       string  \000MRM                 Minolta Dimage camera raw image data
1031
1032 # Summary: DjVu image / document
1033 # Extension: .djvu
1034 # Reference: http://djvu.org/docs/DjVu3Spec.djvu
1035 # Submitted by: Stephane Loeuillet <stephane.loeuillet@tiscali.fr>
1036 # Modified by (1): Abel Cheung <abelcheung@gmail.com>
1037 0       string  AT&TFORM
1038 >12     string  DJVM            DjVu multiple page document
1039 !:mime  image/vnd.djvu
1040 >12     string  DJVU            DjVu image or single page document
1041 !:mime  image/vnd.djvu
1042 >12     string  DJVI            DjVu shared document
1043 !:mime  image/vnd.djvu
1044 >12     string  THUM            DjVu page thumbnails
1045 !:mime  image/vnd.djvu
1046
1047 # Originally by Marc Espie
1048 # Modified by Robert Minsk <robertminsk at yahoo.com>
1049 # http://www.openexr.com/openexrfilelayout.pdf
1050 0       lelong          20000630        OpenEXR image data,
1051 !:mime image/x-exr
1052 >4      lelong&0x000000ff x             version %d,
1053 >4      lelong          ^0x00000200     storage: scanline
1054 >4      lelong          &0x00000200     storage: tiled
1055 >8      search/0x1000   compression\0   \b, compression:
1056 >>&16   byte            0               none
1057 >>&16   byte            1               rle
1058 >>&16   byte            2               zips
1059 >>&16   byte            3               zip
1060 >>&16   byte            4               piz
1061 >>&16   byte            5               pxr24
1062 >>&16   byte            6               b44
1063 >>&16   byte            7               b44a
1064 >>&16   byte            8               dwaa
1065 >>&16   byte            9               dwab
1066 >>&16   byte            >9              unknown
1067 >8       search/0x1000  dataWindow\0    \b, dataWindow:
1068 >>&10   lelong          x               (%d
1069 >>&14   lelong          x               %d)-
1070 >>&18   lelong          x               \b(%d
1071 >>&22   lelong          x               %d)
1072 >8      search/0x1000   displayWindow\0 \b, displayWindow:
1073 >>&10   lelong          x               (%d
1074 >>&14   lelong          x               %d)-
1075 >>&18   lelong          x               \b(%d
1076 >>&22   lelong          x               %d)
1077 >8      search/0x1000   lineOrder\0      \b, lineOrder:
1078 >>&14   byte            0               increasing y
1079 >>&14   byte            1               decreasing y
1080 >>&14   byte            2               random y
1081 >>&14   byte            >2              unknown
1082
1083 # SMPTE Digital Picture Exchange Format, SMPTE DPX
1084 #
1085 # ANSI/SMPTE 268M-1994, SMPTE Standard for File Format for Digital
1086 # Moving-Picture Exchange (DPX), v1.0, 18 February 1994
1087 # Robert Minsk <robertminsk at yahoo.com>
1088 # Modified by Harry Mallon <hjmallon at gmail.com>
1089 0       string          SDPX    DPX image data, big-endian,
1090 !:mime image/x-dpx
1091 >0      use             dpx_info
1092 0       string          XPDS    DPX image data, little-endian,
1093 !:mime image/x-dpx
1094 >0      use             \^dpx_info
1095
1096 0       name            dpx_info
1097 >768    beshort         <4
1098 >>772   belong          x       %dx
1099 >>776   belong          x       \b%d,
1100 >768    beshort         >3
1101 >>776   belong          x       %dx
1102 >>772   belong          x       \b%d,
1103 >768    beshort         0       left to right/top to bottom
1104 >768    beshort         1       right to left/top to bottom
1105 >768    beshort         2       left to right/bottom to top
1106 >768    beshort         3       right to left/bottom to top
1107 >768    beshort         4       top to bottom/left to right
1108 >768    beshort         5       top to bottom/right to left
1109 >768    beshort         6       bottom to top/left to right
1110 >768    beshort         7       bottom to top/right to left
1111
1112 # From: Tom Hilinski <tom.hilinski@comcast.net>
1113 # http://www.unidata.ucar.edu/packages/netcdf/
1114 0       string  CDF\001                 NetCDF Data Format data
1115
1116 #-----------------------------------------------------------------------
1117 # Hierarchical Data Format, used to facilitate scientific data exchange
1118 # specifications at http://hdf.ncsa.uiuc.edu/
1119 0       belong  0x0e031301      Hierarchical Data Format (version 4) data
1120 !:mime  application/x-hdf
1121 0       string  \211HDF\r\n\032\n       Hierarchical Data Format (version 5) data
1122 !:mime  application/x-hdf
1123 512     string  \211HDF\r\n\032\n       Hierarchical Data Format (version 5) with 512 bytes user block
1124 !:mime  application/x-hdf
1125 1024    string  \211HDF\r\n\032\n       Hierarchical Data Format (version 5) with 1k user block
1126 !:mime  application/x-hdf
1127 2048    string  \211HDF\r\n\032\n       Hierarchical Data Format (version 5) with 2k user block
1128 !:mime  application/x-hdf
1129 4096    string  \211HDF\r\n\032\n       Hierarchical Data Format (version 5) with 4k user block
1130 !:mime  application/x-hdf
1131
1132
1133 # From: Tobias Burnus <burnus@net-b.de>
1134 # Xara (for a while: Corel Xara) is a graphic package, see
1135 # http://www.xara.com/ for Windows and as GPL application for Linux
1136 0       string  XARA\243\243    Xara graphics file
1137
1138 # http://www.cartesianinc.com/Tech/
1139 0       string  CPC\262         Cartesian Perceptual Compression image
1140 !:mime  image/x-cpi
1141
1142 # From Albert Cahalan <acahalan@gmail.com>
1143 # puredigital used it for the CVS disposable camcorder
1144 #8       lelong  4       ZBM bitmap image data
1145 #>4      leshort x       %u x
1146 #>6      leshort x       %u
1147
1148 # From Albert Cahalan <acahalan@gmail.com>
1149 # uncompressed 5:6:5 HighColor image for OLPC XO firmware icons
1150 0       string C565     OLPC firmware icon image data
1151 >4      leshort x       %u x
1152 >6      leshort x       %u
1153
1154 # Applied Images - Image files from Cytovision
1155 # Gustavo Junior Alves <gjalves@gjalves.com.br>
1156 0       string  \xce\xda\xde\xfa        Cytovision Metaphases file
1157 0       string  \xed\xad\xef\xac        Cytovision Karyotype file
1158 0       string  \x0b\x00\x03\x00        Cytovision FISH Probe file
1159 0       string  \xed\xfe\xda\xbe        Cytovision FLEX file
1160 0       string  \xed\xab\xed\xfe        Cytovision FLEX file
1161 0       string  \xad\xfd\xea\xad        Cytovision RATS file
1162
1163 # Wavelet Scalar Quantization format used in gray-scale fingerprint images
1164 # From Tano M Fotang <mfotang@quanteq.com>
1165 0       string  \xff\xa0\xff\xa8\x00    Wavelet Scalar Quantization image data
1166
1167 # Type:         PCO B16 image files
1168 # URL:          http://www.pco.de/fileadmin/user_upload/db/download/MA_CWDCOPIE_0412b.pdf
1169 # From:         Florian Philipp <florian.philipp@binarywings.net>
1170 # Extension:    .b16
1171 # Description:  Pixel image format produced by PCO Camware, typically used
1172 #               together with PCO cameras.
1173 # Note:         Different versions exist for e.g. 8 bit and 16 bit images.
1174 #               Documentation is incomplete.
1175 0       string/b        PCO-    PCO B16 image data
1176 >12     lelong          x       \b, %dx
1177 >16     lelong          x       \b%d
1178 >20     lelong          0       \b, short header
1179 >20     lelong          -1      \b, extended header
1180 >>24    lelong          0       \b, grayscale
1181 >>>36   lelong          0       linear LUT
1182 >>>36   lelong          1       logarithmic LUT
1183 >>>28   lelong          x       [%d
1184 >>>32   lelong          x       \b,%d]
1185 >>24    lelong          1       \b, color
1186 >>>64   lelong          0       linear LUT
1187 >>>64   lelong          1       logarithmic LUT
1188 >>>40   lelong          x       r[%d
1189 >>>44   lelong          x       \b,%d]
1190 >>>48   lelong          x       g[%d
1191 >>>52   lelong          x       \b,%d]
1192 >>>56   lelong          x       b[%d
1193 >>>60   lelong          x       \b,%d]
1194
1195 # Polar Monitor Bitmap (.pmb) used as logo for Polar Electro watches
1196 # From: Markus Heidelberg <markus.heidelberg at web.de>
1197 0       string/t        [BitmapInfo2]   Polar Monitor Bitmap text
1198 !:mime  image/x-polar-monitor-bitmap
1199
1200 # From: Rick Richardson <rickrich@gmail.com>
1201 # updated by: Joerg Jenderek
1202 # URL: http://techmods.net/nuvi/
1203 0       string  GARMIN\ BITMAP\ 01      Garmin Bitmap file
1204 # extension is also used for
1205 # Sony SRF raw image (image/x-sony-srf)
1206 # SRF map
1207 # Terragen Surface Map (http://www.planetside.co.uk/terragen)
1208 # FileLocator Pro search criteria file (http://www.mythicsoft.com/filelocatorpro)
1209 !:ext srf
1210 #!:mime image/x-garmin-srf
1211 # version 1.00,2.00,2.10,2.40,2.50
1212 >0x2f   string          >0              \b, version %4.4s
1213 # width (2880,2881,3240)
1214 >0x55   uleshort        >0              \b, %dx
1215 # height (80,90)
1216 >>0x53  uleshort        x               \b%d
1217
1218 # Type: Ulead Photo Explorer5 (.pe5)
1219 # URL:  http://www.jisyo.com/cgibin/view.cgi?EXT=pe5 (Japanese)
1220 # From: Simon Horman <horms@debian.org>
1221 0       string  IIO2H                   Ulead Photo Explorer5
1222
1223 # Type: X11 cursor
1224 # URL:  http://webcvs.freedesktop.org/mime/shared-mime-info/freedesktop.org.xml.in?view=markup
1225 # From: Mathias Brodala <info@noctus.net>
1226 0       string  Xcur                    X11 cursor
1227
1228 # Type: Olympus ORF raw images.
1229 # URL:  http://libopenraw.freedesktop.org/wiki/Olympus_ORF
1230 # From: Adam Buchbinder <adam.buchbinder@gmail.com>
1231 0       string          MMOR            Olympus ORF raw image data, big-endian
1232 !:mime  image/x-olympus-orf
1233 0       string          IIRO            Olympus ORF raw image data, little-endian
1234 !:mime  image/x-olympus-orf
1235 0       string          IIRS            Olympus ORF raw image data, little-endian
1236 !:mime  image/x-olympus-orf
1237
1238 # Type: files used in modern AVCHD camcoders to store clip information
1239 # Extension: .cpi
1240 # From: Alexander Danilov <alexander.a.danilov@gmail.com>
1241 0       string  HDMV0100        AVCHD Clip Information
1242
1243 # From: Adam Buchbinder <adam.buchbinder@gmail.com>
1244 # URL: http://local.wasp.uwa.edu.au/~pbourke/dataformats/pic/
1245 # Radiance HDR; usually has .pic or .hdr extension.
1246 0       string  #?RADIANCE\n    Radiance HDR image data
1247 #!mime  image/vnd.radiance
1248
1249 # From: Adam Buchbinder <adam.buchbinder@gmail.com>
1250 # URL: http://www.mpi-inf.mpg.de/resources/pfstools/pfs_format_spec.pdf
1251 # Used by the pfstools packages. The regex matches for the image size could
1252 # probably use some work. The MIME type is made up; if there's one in
1253 # actual common use, it should replace the one below.
1254 0       string  PFS1\x0a        PFS HDR image data
1255 #!mime  image/x-pfs
1256 >1      regex   [0-9]*\                 \b, %s
1257 >>1     regex   \ [0-9]{4}              \bx%s
1258
1259 # Type: Foveon X3F
1260 # URL:  http://www.photofo.com/downloads/x3f-raw-format.pdf
1261 # From: Adam Buchbinder <adam.buchbinder@gmail.com>
1262 # Note that the MIME type isn't defined anywhere that I can find; if
1263 # there's a canonical type for this format, it should replace this one.
1264 0       string  FOVb    Foveon X3F raw image data
1265 !:mime  image/x-x3f
1266 >6      leshort x       \b, version %d.
1267 >4      leshort x       \b%d
1268 >28     lelong  x       \b, %dx
1269 >32     lelong  x       \b%d
1270
1271 # Paint.NET file
1272 # From Adam Buchbinder <adam.buchbinder@gmail.com>
1273 0       string  PDN3    Paint.NET image data
1274 !:mime  image/x-paintnet
1275
1276 # Not really an image.
1277 # From: "Tano M. Fotang" <mfotang@quanteq.com>
1278 0       string  \x46\x4d\x52\x00        ISO/IEC 19794-2 Format Minutiae Record (FMR)
1279
1280 # doc: http://www.shikino.co.jp/eng/products/images/FLOWER.jpg.zip
1281 # example: http://www.shikino.co.jp/eng/products/images/FLOWER.wdp.zip
1282 90      bequad          0x574D50484F544F00      JPEG-XR Image
1283 >98     byte&0x08       =0x08                   \b, hard tiling
1284 >99     byte&0x80       =0x80                   \b, tiling present
1285 >99     byte&0x40       =0x40                   \b, codestream present
1286 >99     byte&0x38       x                       \b, spatial xform=
1287 >99     byte&0x38       0x00                    \bTL
1288 >99     byte&0x38       0x08                    \bBL
1289 >99     byte&0x38       0x10                    \bTR
1290 >99     byte&0x38       0x18                    \bBR
1291 >99     byte&0x38       0x20                    \bBT
1292 >99     byte&0x38       0x28                    \bRB
1293 >99     byte&0x38       0x30                    \bLT
1294 >99     byte&0x38       0x38                    \bLB
1295 >100    byte&0x80       =0x80                   \b, short header
1296 >>102   beshort+1       x                       \b, %d
1297 >>104   beshort+1       x                       \bx%d
1298 >100    byte&0x80       =0x00                   \b, long header
1299 >>102   belong+1        x                       \b, %x
1300 >>106   belong+1        x                       \bx%x
1301 >101    beshort&0xf     x                       \b, bitdepth=
1302 >>101   beshort&0xf     0x0                     \b1-WHITE=1
1303 >>101   beshort&0xf     0x1                     \b8
1304 >>101   beshort&0xf     0x2                     \b16
1305 >>101   beshort&0xf     0x3                     \b16-SIGNED
1306 >>101   beshort&0xf     0x4                     \b16-FLOAT
1307 >>101   beshort&0xf     0x5                     \b(reserved 5)
1308 >>101   beshort&0xf     0x6                     \b32-SIGNED
1309 >>101   beshort&0xf     0x7                     \b32-FLOAT
1310 >>101   beshort&0xf     0x8                     \b5
1311 >>101   beshort&0xf     0x9                     \b10
1312 >>101   beshort&0xf     0xa                     \b5-6-5
1313 >>101   beshort&0xf     0xb                     \b(reserved %d)
1314 >>101   beshort&0xf     0xc                     \b(reserved %d)
1315 >>101   beshort&0xf     0xd                     \b(reserved %d)
1316 >>101   beshort&0xf     0xe                     \b(reserved %d)
1317 >>101   beshort&0xf     0xf                     \b1-BLACK=1
1318 >101    beshort&0xf0    x                       \b, colorfmt=
1319 >>101   beshort&0xf0    0x00                    \bYONLY
1320 >>101   beshort&0xf0    0x10                    \bYUV240
1321 >>101   beshort&0xf0    0x20                    \bYWV422
1322 >>101   beshort&0xf0    0x30                    \bYWV444
1323 >>101   beshort&0xf0    0x40                    \bCMYK
1324 >>101   beshort&0xf0    0x50                    \bCMYKDIRECT
1325 >>101   beshort&0xf0    0x60                    \bNCOMPONENT
1326 >>101   beshort&0xf0    0x70                    \bRGB
1327 >>101   beshort&0xf0    0x80                    \bRGBE
1328 >>101   beshort&0xf0    >0x80                   \b(reserved 0x%x)
1329
1330 # From: Johan van der Knijff <johan.vanderknijff@kb.nl>
1331 #
1332 # BPG (Better Portable Graphics) format
1333 # http://bellard.org/bpg/
1334 # http://fileformats.archiveteam.org/wiki/BPG
1335 #
1336 0       string  \x42\x50\x47\xFB        BPG (Better Portable Graphics)
1337 !:mime  image/bpg
1338
1339 # From: Joerg Jenderek
1340 # URL: https://en.wikipedia.org/wiki/Apple_Icon_Image_format
1341 0       string          icns            Mac OS X icon
1342 !:mime  image/x-icns
1343 !:apple ????icns
1344 !:ext icns
1345 >4      ubelong         >0
1346 # file size
1347 >>4     ubelong         x               \b, %d bytes
1348 # icon type
1349 >>8     string          x               \b, "%4.4s" type
1350
1351 # TIM images
1352 0               lelong          0x00000010      TIM image,
1353 >4              lelong          0x8             4-Bit,
1354 >4              lelong          0x9             8-Bit,
1355 >4              lelong          0x2             15-Bit,
1356 >4              lelong          0x3             24-Bit,
1357 >4              lelong          &8
1358 >>(8.l+12)      leshort         x               Pixel at (%d,
1359 >>(8.l+14)      leshort         x               \b%d)
1360 >>(8.l+16)      leshort         x               Size=%dx
1361 >>(8.l+18)      leshort         x               \b%d,
1362 >>4             lelong          0x8             16 CLUT Entries at
1363 >>4             lelong          0x9             256 CLUT Entries at
1364 >>12            leshort         x               (%d,
1365 >>14            leshort         x               \b%d)
1366 >4              lelong          ^8
1367 >>12            leshort         x               Pixel at (%d,
1368 >>14            leshort         x               \b%d)
1369 >>16            leshort         x               Size=%dx
1370 >>18            leshort         x               \b%d
1371
1372 # MDEC streams
1373 0               lelong          0x80010160      MDEC video stream,
1374 >16             leshort         x               %dx
1375 >18             leshort         x               \b%d
1376 #>8             lelong          x               %d frames
1377 #>4             leshort         x               secCount=%d;
1378 #>6             leshort         x               nSectors=%d;
1379 #>12            lelong          x               frameSize=%d;
1380
1381 # BS encoded bitstreams
1382 2               leshort         0x3800          BS image,
1383 >6              leshort         x               Version %d,
1384 >4              leshort         x               Quantization %d,
1385 >0              leshort         x               (Decompresses to %d words)
1386
1387 # Type: farbfeld image.
1388 # Url: http://tools.suckless.org/farbfeld/
1389 # From: Ian D. Scott <ian@iandouglasscott.com>
1390 #
1391 0               string          farbfeld        farbfeld image data,
1392 >8              ubelong         x               %dx
1393 >12             ubelong         x               \b%d
1394
1395 # Type: Sega PVR image.
1396 # From: David Korth <gerbilsoft@gerbilsoft.com>
1397 # References:
1398 # - http://fabiensanglard.net/Mykaruga/tools/segaPVRFormat.txt
1399 # - https://github.com/yazgoo/pvrx2png
1400 # - https://github.com/nickworonekin/puyotools
1401
1402 # Sega PVR header.
1403 0       name    sega-pvr-image-header
1404 >0x0C   leshort x       %d x
1405 >0x0E   leshort x       %d
1406 # Image format.
1407 >0x08   byte    0       \b, ARGB1555
1408 >0x08   byte    1       \b, RGB565
1409 >0x08   byte    2       \b, ARGB4444
1410 >0x08   byte    3       \b, YUV442
1411 >0x08   byte    4       \b, Bump
1412 >0x08   byte    5       \b, 4bpp
1413 >0x08   byte    6       \b, 8bpp
1414 # Image data type.
1415 >0x09   byte    0x01    \b, square twiddled
1416 >0x09   byte    0x02    \b, square twiddled & mipmap
1417 >0x09   byte    0x03    \b, VQ
1418 >0x09   byte    0x04    \b, VQ & mipmap
1419 >0x09   byte    0x05    \b, 8-bit CLUT twiddled
1420 >0x09   byte    0x06    \b, 4-bit CLUT twiddled
1421 >0x09   byte    0x07    \b, 8-bit direct twiddled
1422 >0x09   byte    0x08    \b, 4-bit direct twiddled
1423 >0x09   byte    0x09    \b, rectangle
1424 >0x09   byte    0x0B    \b, rectangular stride
1425 >0x09   byte    0x0D    \b, rectangular twiddled
1426 >0x09   byte    0x10    \b, small VQ
1427 >0x09   byte    0x11    \b, small VQ & mipmap
1428 >0x09   byte    0x12    \b, square twiddled & mipmap
1429
1430 # Sega PVR (Xbox) image header.
1431 # Contains an embedded DirectDraw surface instead of PVR data.
1432 0       name    sega-pvr-xbox-dds-header
1433 >16     lelong  x       %d x
1434 >12     lelong  x       %d,
1435 >84     string  x       %.4s
1436
1437 # Sega PVR image.
1438 0       string  PVRT
1439 >0x10   string  DDS\040\174\000\000\000 Sega PVR (Xbox) image:
1440 >>0x20  use     sega-pvr-xbox-dds-header
1441 >0x10   belong  !0x44445320             Sega PVR image:
1442 >>0     use     sega-pvr-image-header
1443
1444 # Sega PVR image with GBIX.
1445 0       string  GBIX
1446 >0x10   string  PVRT
1447 >>0x10  string  DDS\040\174\000\000\000 Sega PVR (Xbox) image:
1448 >>>0x20 use     sega-pvr-xbox-dds-header
1449 >>0x10  belong  !0x44445320             Sega PVR image:
1450 >>>0x10 use     sega-pvr-image-header
1451 >>0x08  lelong  x       \b, global index = %u
1452
1453 # Sega GVR header.
1454 0       name    sega-gvr-image-header
1455 >0x0C   beshort x       %d x
1456 >0x0E   beshort x       %d
1457 # Image data format.
1458 >0x0B   byte    0       \b, I4
1459 >0x0B   byte    1       \b, I8
1460 >0x0B   byte    2       \b, IA4
1461 >0x0B   byte    3       \b, IA8
1462 >0x0B   byte    4       \b, RGB565
1463 >0x0B   byte    5       \b, RGB5A3
1464 >0x0B   byte    6       \b, ARGB8888
1465 >0x0B   byte    8       \b, CI4
1466 >0x0B   byte    9       \b, CI8
1467 >0x0B   byte    14      \b, DXT1
1468
1469 # Sega GVR image.
1470 0       string  GVRT    Sega GVR image:
1471 >0x10   use     sega-gvr-image-header
1472
1473 # Sega GVR image with GBIX.
1474 0       string  GBIX
1475 >0x10   string  GVRT    Sega GVR image:
1476 >>0x10  use     sega-gvr-image-header
1477 >>0x08  belong  x       \b, global index = %u
1478
1479 # Light Field Picture
1480 # Documentation: http://optics.miloush.net/lytro/TheFileFormat.aspx
1481 # Typical file extensions: .lfp .lfr .lfx
1482
1483 0       belong  0x894C4650
1484 >4      belong  0x0D0A1A0A
1485 >12     belong  0x00000000      Lytro Light Field Picture
1486 >8      belong  x               \b, version %d
1487
1488 # Type: Vision Research Phantom CINE Format
1489 # URL: https://www.phantomhighspeed.com/
1490 # URL2: http://phantomhighspeed.force.com/vriknowledge/servlet/fileField?id=0BEU0000000Cfyk
1491 # From: Harry Mallon <hjmallon at gmail.com>
1492 #
1493 # This has a short "CI" code but the 44 is the size of the struct which is
1494 # stable
1495 0       string  CI
1496 >2      leshort 44              Vision Research CINE Video,
1497 >>4     leshort 0               Grayscale,
1498 >>4     leshort 1               JPEG Compressed,
1499 >>4     leshort 2               RAW,
1500 >>6     leshort x               version %d,
1501 >>20    lelong  x               %d frames,
1502 >>48    lelong  x               %dx
1503 >>52    lelong  x               \b%d
1504
1505 # Type: ARRI Raw Image
1506 # Info: SMPTE RDD30:2014
1507 # From: Harry Mallon <hjmallon at gmail.com>
1508 0       string ARRI             ARRI ARI image data,
1509 >4      lelong 0x78563412       little-endian,
1510 >4      lelong 0x12345678       big-endian,
1511 >12     lelong x                version %d,
1512 >20     lelong x                %dx
1513 >24     lelong x                \b%d