jlec        15/06/15 08:14:18

  Added:                pillow-2.8.1-ico-backport.patch
  Log:
  backport patch for endianess of ico files, hopefully fixing bug #551422 & bug 
#551424
  
  (Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key 
E9402A79B03529A2!)

Revision  Changes    Path
1.1                  dev-python/pillow/files/pillow-2.8.1-ico-backport.patch

file : 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pillow/files/pillow-2.8.1-ico-backport.patch?rev=1.1&view=markup
plain: 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pillow/files/pillow-2.8.1-ico-backport.patch?rev=1.1&content-type=text/plain

Index: pillow-2.8.1-ico-backport.patch
===================================================================
 PIL/IcoImagePlugin.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/PIL/IcoImagePlugin.py b/PIL/IcoImagePlugin.py
index b4817db..dff4efc 100644
--- a/PIL/IcoImagePlugin.py
+++ b/PIL/IcoImagePlugin.py
@@ -49,7 +49,7 @@ def _save(im, fp, filename):
     filter(lambda x: False if (x[0] > width or x[1] > height or
                                x[0] > 255 or x[1] > 255) else True, sizes)
     sizes = sorted(sizes, key=lambda x: x[0])
-    fp.write(struct.pack("H", len(sizes)))  # idCount(2)
+    fp.write(struct.pack("<H", len(sizes)))  # idCount(2)
     offset = fp.tell() + len(sizes)*16
     for size in sizes:
         width, height = size
@@ -58,7 +58,7 @@ def _save(im, fp, filename):
         fp.write(b"\0")  # bColorCount(1)
         fp.write(b"\0")  # bReserved(1)
         fp.write(b"\0\0")  # wPlanes(2)
-        fp.write(struct.pack("H", 32))  # wBitCount(2)
+        fp.write(struct.pack("<H", 32))  # wBitCount(2)
 
         image_io = BytesIO()
         tmp = im.copy()
@@ -67,8 +67,8 @@ def _save(im, fp, filename):
         image_io.seek(0)
         image_bytes = image_io.read()
         bytes_len = len(image_bytes)
-        fp.write(struct.pack("I", bytes_len))  # dwBytesInRes(4)
-        fp.write(struct.pack("I", offset))  # dwImageOffset(4)
+        fp.write(struct.pack("<I", bytes_len))  # dwBytesInRes(4)
+        fp.write(struct.pack("<I", offset))  # dwImageOffset(4)
         current = fp.tell()
         fp.seek(offset)
         fp.write(image_bytes)




Reply via email to