jpeg 8.3 KB

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