anka-imaging-tiffendian.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --- Imaging-1.1.7-orig/PIL/TiffImagePlugin.py 2009-11-01 02:44:12.000000000 +0200
  2. +++ Imaging-1.1.7/PIL/TiffImagePlugin.py 2012-11-13 03:45:11.280000132 +0200
  3. @@ -69,7 +69,7 @@
  4. def il32(c,o=0):
  5. return ord(c[o]) + (ord(c[o+1])<<8) + (ord(c[o+2])<<16) + (ord(c[o+3])<<24)
  6. def ol16(i):
  7. - return chr(i&255) + chr(i>>8&255)
  8. + return chr(i>>8&255) + chr(i&255)
  9. def ol32(i):
  10. return chr(i&255) + chr(i>>8&255) + chr(i>>16&255) + chr(i>>24&255)
  11. @@ -197,6 +197,8 @@
  12. }
  13. PREFIXES = ["MM\000\052", "II\052\000", "II\xBC\000"]
  14. +PREFIX_TO_BYTEORDER = {"MM":"b", "II":"l"}
  15. +BYTEORDER_TO_PREFIX = {"b":"MM", "l":"II"}
  16. def _accept(prefix):
  17. return prefix[:4] in PREFIXES
  18. @@ -219,6 +221,8 @@
  19. self.o16, self.o32 = ol16, ol32
  20. else:
  21. raise SyntaxError("not a TIFF IFD")
  22. + self.byteorder = PREFIX_TO_BYTEORDER[self.prefix]
  23. +
  24. self.reset()
  25. def reset(self):
  26. @@ -749,7 +753,7 @@
  27. def _save(im, fp, filename):
  28. try:
  29. - rawmode, prefix, photo, format, bits, extra = SAVE_INFO[im.mode]
  30. + rawmode, prefix, byteorder, photo, format, bits, extra = SAVE_INFO[im.mode]
  31. except KeyError:
  32. raise IOError, "cannot write mode %s as TIFF" % im.mode