jpeg 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #------------------------------------------------------------------------------
  2. # $File: jpeg,v 1.30 2016/07/04 15:18:23 christos Exp $
  3. # JPEG images
  4. # SunOS 5.5.1 had
  5. #
  6. # 0 string \377\330\377\340 JPEG file
  7. # 0 string \377\330\377\356 JPG file
  8. #
  9. # both of which turn into "JPEG image data" here.
  10. #
  11. 0 beshort 0xffd8 JPEG image data
  12. !:mime image/jpeg
  13. !:apple 8BIMJPEG
  14. !:strength *3
  15. !:ext jpeg/jpg/jpe/jfif
  16. >6 string JFIF \b, JFIF standard
  17. # The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
  18. # in a vain attempt to add image size reporting for JFIF. Note that these
  19. # tests are not fool-proof since some perfectly valid JPEGs are currently
  20. # impossible to specify in magic(4) format.
  21. # First, a little JFIF version info:
  22. >>11 byte x \b %d.
  23. >>12 byte x \b%02d
  24. # Next, the resolution or aspect ratio of the image:
  25. >>13 byte 0 \b, aspect ratio
  26. >>13 byte 1 \b, resolution (DPI)
  27. >>13 byte 2 \b, resolution (DPCM)
  28. >>14 beshort x \b, density %dx
  29. >>16 beshort x \b%d
  30. >>4 beshort x \b, segment length %d
  31. # Next, show thumbnail info, if it exists:
  32. >>18 byte !0 \b, thumbnail %dx
  33. >>>19 byte x \b%d
  34. >6 string Exif \b, Exif standard: [
  35. >>12 indirect/r x
  36. >>12 string x \b]
  37. # Jump to the first segment
  38. >(4.S+4) use jpeg_segment
  39. # This uses recursion...
  40. 0 name jpeg_segment
  41. >0 beshort 0xFFFE
  42. # Recursion handled by FFE0
  43. #>>(2.S+2) use jpeg_segment
  44. >>2 pstring/HJ x \b, comment: "%s"
  45. >0 beshort 0xFFC0
  46. >>(2.S+2) use jpeg_segment
  47. >>4 byte x \b, baseline, precision %d
  48. >>7 beshort x \b, %dx
  49. >>5 beshort x \b%d
  50. >>9 byte x \b, frames %d
  51. >0 beshort 0xFFC1
  52. >>(2.S+2) use jpeg_segment
  53. >>4 byte x \b, extended sequential, precision %d
  54. >>7 beshort x \b, %dx
  55. >>5 beshort x \b%d
  56. >>9 byte x \b, frames %d
  57. >0 beshort 0xFFC2
  58. >>(2.S+2) use jpeg_segment
  59. >>4 byte x \b, progressive, precision %d
  60. >>7 beshort x \b, %dx
  61. >>5 beshort x \b%d
  62. >>9 byte x \b, frames %d
  63. # Define Huffman Tables
  64. >0 beshort 0xFFC4
  65. >>(2.S+2) use jpeg_segment
  66. >0 beshort 0xFFE1
  67. # Recursion handled by FFE0
  68. #>>(2.S+2) use jpeg_segment
  69. >>4 string Exif \b, Exif Standard: [
  70. >>>10 indirect/r x
  71. >>>10 string x \b]
  72. # Application specific markers
  73. >0 beshort&0xFFE0 =0xFFE0
  74. >>(2.S+2) use jpeg_segment
  75. # DB: Define Quantization tables
  76. # DD: Define Restart interval [XXX: wrong here, it is 4 bytes]
  77. # D8: Start of image
  78. # D9: End of image
  79. # Dn: Restart
  80. >0 beshort&0xFFD0 =0xFFD0
  81. >>0 beshort&0xFFE0 !0xFFE0
  82. >>>(2.S+2) use jpeg_segment
  83. #>0 beshort x unknown 0x%x
  84. #>>(2.S+2) use jpeg_segment
  85. # HSI is Handmade Software's proprietary JPEG encoding scheme
  86. 0 string hsi1 JPEG image data, HSI proprietary
  87. # From: David Santinoli <david@santinoli.com>
  88. 0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000
  89. # From: Johan van der Knijff <johan.vanderknijff@kb.nl>
  90. # Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes
  91. # https://github.com/bitsgalore/jp2kMagic
  92. #
  93. # Now read value of 'Brand' field, which yields a few possibilities:
  94. >20 string \x6a\x70\x32\x20 Part 1 (JP2)
  95. !:mime image/jp2
  96. >20 string \x6a\x70\x78\x20 Part 2 (JPX)
  97. !:mime image/jpx
  98. >20 string \x6a\x70\x6d\x20 Part 6 (JPM)
  99. !:mime image/jpm
  100. >20 string \x6d\x6a\x70\x32 Part 3 (MJ2)
  101. !:mime video/mj2
  102. # Type: JPEG 2000 codesream
  103. # From: Mathieu Malaterre <mathieu.malaterre@gmail.com>
  104. 0 belong 0xff4fff51 JPEG 2000 codestream
  105. 45 beshort 0xff52
  106. # JPEG extended range
  107. 0 string \x49\x49\xbc
  108. >3 byte 1
  109. >>4 lelong%2 0 JPEG-XR
  110. !:mime image/jxr
  111. !:ext jxr