mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	fix Python 2 compatibility
This commit is contained in:
		
							parent
							
								
									12cea19280
								
							
						
					
					
						commit
						a9cb1281f4
					
				| 
						 | 
					@ -370,7 +370,7 @@ def getheader(im, palette=None, info=None):
 | 
				
			||||||
                for i in usedPaletteColors:
 | 
					                for i in usedPaletteColors:
 | 
				
			||||||
                    paletteBytes += o8(i)*3
 | 
					                    paletteBytes += o8(i)*3
 | 
				
			||||||
            else :
 | 
					            else :
 | 
				
			||||||
                paletteBytes = bytes([i//3 for i in range(768)])
 | 
					                paletteBytes = bytearray([i//3 for i in range(768)])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # TODO improve this, maybe add numpy support
 | 
					        # TODO improve this, maybe add numpy support
 | 
				
			||||||
        # replace the palette color id of all pixel with the new id
 | 
					        # replace the palette color id of all pixel with the new id
 | 
				
			||||||
| 
						 | 
					@ -386,7 +386,7 @@ def getheader(im, palette=None, info=None):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # calculate the palette size for the header
 | 
					    # calculate the palette size for the header
 | 
				
			||||||
    import math
 | 
					    import math
 | 
				
			||||||
    colorTableSize = math.ceil(math.log(len(paletteBytes)//3, 2))-1
 | 
					    colorTableSize = int(math.ceil(math.log(len(paletteBytes)//3, 2)))-1
 | 
				
			||||||
    if colorTableSize < 0: colorTableSize = 0
 | 
					    if colorTableSize < 0: colorTableSize = 0
 | 
				
			||||||
    s.append(o8(colorTableSize + 128)) # size of global color table + global color table flag
 | 
					    s.append(o8(colorTableSize + 128)) # size of global color table + global color table flag
 | 
				
			||||||
    s.append(o8(0) + o8(0)) # background + reserved/aspect
 | 
					    s.append(o8(0) + o8(0)) # background + reserved/aspect
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										5
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								setup.py
									
									
									
									
									
								
							| 
						 | 
					@ -285,10 +285,9 @@ class pil_build_ext(build_ext):
 | 
				
			||||||
            elif _find_library_file(self, "tk" + TCL_VERSION):
 | 
					            elif _find_library_file(self, "tk" + TCL_VERSION):
 | 
				
			||||||
                feature.tk = "tk" + TCL_VERSION
 | 
					                feature.tk = "tk" + TCL_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (
 | 
					        if (_find_include_file(self, "webp/encode.h") and
 | 
				
			||||||
                _find_include_file(self, "webp/encode.h") and
 | 
					 | 
				
			||||||
                _find_include_file(self, "webp/decode.h")):
 | 
					                _find_include_file(self, "webp/decode.h")):
 | 
				
			||||||
            if _find_library_file(self, "webp"):
 | 
					            if _find_library_file(self, "webp"): # in googles precompiled zip it is call "libwebp"
 | 
				
			||||||
                feature.webp = "webp"
 | 
					                feature.webp = "webp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #
 | 
					        #
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user