jpeg 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #------------------------------------------------------------------------------
  2. # JPEG images
  3. # SunOS 5.5.1 had
  4. #
  5. # 0 string \377\330\377\340 JPEG file
  6. # 0 string \377\330\377\356 JPG file
  7. #
  8. # both of which turn into "JPEG image data" here.
  9. #
  10. 0 beshort 0xffd8 JPEG image data
  11. >6 string JFIF \b, JFIF standard
  12. # The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
  13. # in a vain attempt to add image size reporting for JFIF. Note that these
  14. # tests are not fool-proof since some perfectly valid JPEGs are currently
  15. # impossible to specify in magic(4) format.
  16. # First, a little JFIF version info:
  17. >>11 byte x \b %d.
  18. >>12 byte x \b%02d
  19. # Next, the resolution or aspect ratio of the image:
  20. #>>13 byte 0 \b, aspect ratio
  21. #>>13 byte 1 \b, resolution (DPI)
  22. #>>13 byte 2 \b, resolution (DPCM)
  23. #>>4 beshort x \b, segment length %d
  24. # Next, show thumbnail info, if it exists:
  25. >>18 byte !0 \b, thumbnail %dx
  26. >>>19 byte x \b%d
  27. # EXIF moved down here to avoid reporting a bogus version number,
  28. # and EXIF version number printing added.
  29. # - Patrik R=E5dman <patrik+file-magic@iki.fi>
  30. >6 string Exif \b, EXIF standard
  31. # Look for EXIF IFD offset in IFD 0, and then look for EXIF version tag in EXIF IFD.
  32. # All possible combinations of entries have to be enumerated, since no looping
  33. # is possible. And both endians are possible...
  34. # The combinations included below are from real-world JPEGs.
  35. # Little-endian
  36. >>12 string II
  37. # IFD 0 Entry #5:
  38. >>>70 leshort 0x8769
  39. # EXIF IFD Entry #1:
  40. >>>>(78.l+14) leshort 0x9000
  41. >>>>>(78.l+23) byte x %c
  42. >>>>>(78.l+24) byte x \b.%c
  43. >>>>>(78.l+25) byte !0x30 \b%c
  44. # IFD 0 Entry #9:
  45. >>>118 leshort 0x8769
  46. # EXIF IFD Entry #3:
  47. >>>>(126.l+38) leshort 0x9000
  48. >>>>>(126.l+47) byte x %c
  49. >>>>>(126.l+48) byte x \b.%c
  50. >>>>>(126.l+49) byte !0x30 \b%c
  51. # IFD 0 Entry #10
  52. >>>130 leshort 0x8769
  53. # EXIF IFD Entry #3:
  54. >>>>(138.l+38) leshort 0x9000
  55. >>>>>(138.l+47) byte x %c
  56. >>>>>(138.l+48) byte x \b.%c
  57. >>>>>(138.l+49) byte !0x30 \b%c
  58. # EXIF IFD Entry #4:
  59. >>>>(138.l+50) leshort 0x9000
  60. >>>>>(138.l+59) byte x %c
  61. >>>>>(138.l+60) byte x \b.%c
  62. >>>>>(138.l+61) byte !0x30 \b%c
  63. # EXIF IFD Entry #5:
  64. >>>>(138.l+62) leshort 0x9000
  65. >>>>>(138.l+71) byte x %c
  66. >>>>>(138.l+72) byte x \b.%c
  67. >>>>>(138.l+73) byte !0x30 \b%c
  68. # IFD 0 Entry #11
  69. >>>142 leshort 0x8769
  70. # EXIF IFD Entry #3:
  71. >>>>(150.l+38) leshort 0x9000
  72. >>>>>(150.l+47) byte x %c
  73. >>>>>(150.l+48) byte x \b.%c
  74. >>>>>(150.l+49) byte !0x30 \b%c
  75. # EXIF IFD Entry #4:
  76. >>>>(150.l+50) leshort 0x9000
  77. >>>>>(150.l+59) byte x %c
  78. >>>>>(150.l+60) byte x \b.%c
  79. >>>>>(150.l+61) byte !0x30 \b%c
  80. # EXIF IFD Entry #5:
  81. >>>>(150.l+62) leshort 0x9000
  82. >>>>>(150.l+71) byte x %c
  83. >>>>>(150.l+72) byte x \b.%c
  84. >>>>>(150.l+73) byte !0x30 \b%c
  85. # Big-endian
  86. >>12 string MM
  87. # IFD 0 Entry #9:
  88. >>>118 beshort 0x8769
  89. # EXIF IFD Entry #1:
  90. >>>>(126.L+14) beshort 0x9000
  91. >>>>>(126.L+23) byte x %c
  92. >>>>>(126.L+24) byte x \b.%c
  93. >>>>>(126.L+25) byte !0x30 \b%c
  94. # EXIF IFD Entry #3:
  95. >>>>(126.L+38) beshort 0x9000
  96. >>>>>(126.L+47) byte x %c
  97. >>>>>(126.L+48) byte x \b.%c
  98. >>>>>(126.L+49) byte !0x30 \b%c
  99. # IFD 0 Entry #10
  100. >>>130 beshort 0x8769
  101. # EXIF IFD Entry #3:
  102. >>>>(138.L+38) beshort 0x9000
  103. >>>>>(138.L+47) byte x %c
  104. >>>>>(138.L+48) byte x \b.%c
  105. >>>>>(138.L+49) byte !0x30 \b%c
  106. # EXIF IFD Entry #5:
  107. >>>>(138.L+62) beshort 0x9000
  108. >>>>>(138.L+71) byte x %c
  109. >>>>>(138.L+72) byte x \b.%c
  110. >>>>>(138.L+73) byte !0x30 \b%c
  111. # IFD 0 Entry #11
  112. >>>142 beshort 0x8769
  113. # EXIF IFD Entry #4:
  114. >>>>(150.L+50) beshort 0x9000
  115. >>>>>(150.L+59) byte x %c
  116. >>>>>(150.L+60) byte x \b.%c
  117. >>>>>(150.L+61) byte !0x30 \b%c
  118. # Here things get sticky. We can do ONE MORE marker segment with
  119. # indirect addressing, and that's all. It would be great if we could
  120. # do pointer arithemetic like in an assembler language. Christos?
  121. # And if there was some sort of looping construct to do searches, plus a few
  122. # named accumulators, it would be even more effective...
  123. # At least we can show a comment if no other segments got inserted before:
  124. >(4.S+5) byte 0xFE
  125. >>(4.S+8) string >\0 \b, comment: "%s"
  126. #>(4.S+5) byte 0xFE \b, comment
  127. #>>(4.S+6) beshort x \b length=%d
  128. #>>(4.S+8) string >\0 \b, "%s"
  129. # Or, we can show the encoding type (I've included only the three most common)
  130. # and image dimensions if we are lucky and the SOFn (image segment) is here:
  131. >(4.S+5) byte 0xC0 \b, baseline
  132. >>(4.S+6) byte x \b, precision %d
  133. >>(4.S+7) beshort x \b, %dx
  134. >>(4.S+9) beshort x \b%d
  135. >(4.S+5) byte 0xC1 \b, extended sequential
  136. >>(4.S+6) byte x \b, precision %d
  137. >>(4.S+7) beshort x \b, %dx
  138. >>(4.S+9) beshort x \b%d
  139. >(4.S+5) byte 0xC2 \b, progressive
  140. >>(4.S+6) byte x \b, precision %d
  141. >>(4.S+7) beshort x \b, %dx
  142. >>(4.S+9) beshort x \b%d
  143. # I've commented-out quantisation table reporting. I doubt anyone cares yet.
  144. #>(4.S+5) byte 0xDB \b, quantisation table
  145. #>>(4.S+6) beshort x \b length=%d
  146. #>14 beshort x \b, %d x
  147. #>16 beshort x \b %d
  148. # HSI is Handmade Software's proprietary JPEG encoding scheme
  149. 0 string hsi1 JPEG image data, HSI proprietary
  150. # From: David Santinoli <david@santinoli.com>
  151. 0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 image data