File tree Expand file tree Collapse file tree 3 files changed +133
-239
lines changed Expand file tree Collapse file tree 3 files changed +133
-239
lines changed Original file line number Diff line number Diff line change @@ -669,12 +669,12 @@ def dump(self):
669669 values = []
670670 for field in self ._fields :
671671 val = getattr (self , field .name )
672- if not isinstance (val , basestring ):
672+ if not isinstance (val , ( str , bytes ) ):
673673 values .append (val )
674674 s += struct_symbols [field .size ]
675675 else :
676676 s += 'B' * len (val )
677- values .extend (struct .unpack ('>' + 'B' * len (val ), val ))
677+ values .extend (struct .unpack ('>' + 'B' * len (val ), bytearray ( val , encoding = 'utf-8' ) ))
678678
679679
680680 return struct .pack (s , * values )
@@ -984,7 +984,7 @@ def parse_image(self, image):
984984 for icon_s in icon_sizes :
985985 icns_element = ICNSElement ()
986986
987- im_data = image_utils .resize (image , (icon_s , icon_s ))
987+ im_data = image_utils .resize (image , (int ( icon_s ), int ( icon_s ) ))
988988
989989 png_file = png .Reader (bytes = im_data )
990990
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ def resize(image, size):
99 image .thumbnail (size , im .ANTIALIAS )
1010 offset = [0 ,0 ]
1111 if image .size [0 ] >= image .size [1 ]:
12- offset [1 ] = back .size [1 ]/ 2 - image .size [1 ]/ 2
12+ offset [1 ] = int ( back .size [1 ]/ 2 - image .size [1 ]/ 2 )
1313 else :
14- offset [0 ] = back .size [0 ]/ 2 - image .size [0 ]/ 2
14+ offset [0 ] = int ( back .size [0 ]/ 2 - image .size [0 ]/ 2 )
1515 back .paste (image , tuple (offset ))
1616 back .save (output , image .format )
1717 contents = output .getvalue ()
You can’t perform that action at this time.
0 commit comments