jpeg 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. >14 beshort x \b X%d:
  24. >16 beshort x \bY%d
  25. #>4 beshort x \b, segment length %d
  26. # Next, show thumbnail info, if it exists:
  27. >18 byte !0 \b, thumbnail %dx
  28. >>19 byte x \b%d
  29. # Here things get sticky. We can do ONE MORE marker segment with
  30. # indirect addressing, and that's all. It would be great if we could
  31. # do pointer arithemetic like in an assembler language. Christos?
  32. # And if there was some sort of looping construct to do searches, plus a few
  33. # named accumulators, it would be even more effective...
  34. # At least we can show a comment if no other segments got inserted before:
  35. >(4.S+5) byte 0xFE
  36. >>(4.S+8) string >\0 \b, "%s"
  37. #>(4.S+5) byte 0xFE \b, comment
  38. #>>(4.S+6) beshort x \b length=%d
  39. #>>(4.S+8) string >\0 \b, "%s"
  40. # Or, we can show the encoding type (I've included only the three most common)
  41. # and image dimensions if we are lucky and the SOFn (image segment) is here:
  42. >(4.S+5) byte 0xC0 \b, baseline
  43. >>(4.S+6) byte x \b, precision %d
  44. >>(4.S+7) beshort x \b, %dx
  45. >>(4.S+9) beshort x \b%d
  46. >(4.S+5) byte 0xC1 \b, extended sequential
  47. >>(4.S+6) byte x \b, precision %d
  48. >>(4.S+7) beshort x \b, %dx
  49. >>(4.S+9) beshort x \b%d
  50. >(4.S+5) byte 0xC2 \b, progressive
  51. >>(4.S+6) byte x \b, precision %d
  52. >>(4.S+7) beshort x \b, %dx
  53. >>(4.S+9) beshort x \b%d
  54. # I've commented-out quantisation table reporting. I doubt anyone cares yet.
  55. #>(4.S+5) byte 0xDB \b, quantisation table
  56. #>>(4.S+6) beshort x \b length=%d
  57. # HSI is Handmade Software's proprietary JPEG encoding scheme
  58. 0 string hsi1 JPEG image data, HSI proprietary