jpeg 2.4 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. >6 string Exif \b, EXIF standard
  13. # The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
  14. # in a vain attempt to add image size reporting for JFIF. Note that these
  15. # tests are not fool-proof since some perfectly valid JPEGs are currently
  16. # impossible to specify in magic(4) format.
  17. # First, a little JFIF version info:
  18. >11 byte x \b %d.
  19. >12 byte x \b%02d
  20. # Next, the resolution or aspect ratio of the image:
  21. >13 byte 0 \b, aspect ratio
  22. >13 byte 1 \b, resolution (DPI)
  23. >13 byte 2 \b, resolution (DPCM)
  24. #>4 beshort x \b, segment length %d
  25. # Next, show thumbnail info, if it exists:
  26. >18 byte !0 \b, thumbnail %dx
  27. >>19 byte x \b%d
  28. # Here things get sticky. We can do ONE MORE marker segment with
  29. # indirect addressing, and that's all. It would be great if we could
  30. # do pointer arithemetic like in an assembler language. Christos?
  31. # And if there was some sort of looping construct to do searches, plus a few
  32. # named accumulators, it would be even more effective...
  33. # At least we can show a comment if no other segments got inserted before:
  34. >(4.S+5) byte 0xFE
  35. >>(4.S+8) string >\0 \b, "%s"
  36. #>(4.S+5) byte 0xFE \b, comment
  37. #>>(4.S+6) beshort x \b length=%d
  38. #>>(4.S+8) string >\0 \b, "%s"
  39. # Or, we can show the encoding type (I've included only the three most common)
  40. # and image dimensions if we are lucky and the SOFn (image segment) is here:
  41. >(4.S+5) byte 0xC0 \b, baseline
  42. >>(4.S+6) byte x \b, precision %d
  43. >>(4.S+7) beshort x \b, %dx
  44. >>(4.S+9) beshort x \b%d
  45. >(4.S+5) byte 0xC1 \b, extended sequential
  46. >>(4.S+6) byte x \b, precision %d
  47. >>(4.S+7) beshort x \b, %dx
  48. >>(4.S+9) beshort x \b%d
  49. >(4.S+5) byte 0xC2 \b, progressive
  50. >>(4.S+6) byte x \b, precision %d
  51. >>(4.S+7) beshort x \b, %dx
  52. >>(4.S+9) beshort x \b%d
  53. # I've commented-out quantisation table reporting. I doubt anyone cares yet.
  54. #>(4.S+5) byte 0xDB \b, quantisation table
  55. #>>(4.S+6) beshort x \b length=%d
  56. >14 beshort x \b, %d x
  57. >16 beshort x \b %d
  58. # HSI is Handmade Software's proprietary JPEG encoding scheme
  59. 0 string hsi1 JPEG image data, HSI proprietary