(img)
return layer
return a white-background-color image having the img in exact center
return a white-background-color image having the img in exact center
return a white - background - color image having the img in exact center
def makeSquare(img):
  "return a white-background-color image having the img in exact center"
  size = (max(img.size),)*2
  layer = Image.new('RGB', size, (255,255,255,0))
  layer.paste(img, tuple(map(lambda x:(x[0]-x[1])//2, zip(size, img.size))))
  return layer
def makeSquare ( img ) : size = ( max ( img . size ) , ) * 2 layer = Image . new ( 'RGB' , size , ( 255 , 255 , 255 , 0 ) ) layer . paste ( img , tuple ( map ( lambda x : ( x [ 0 ] - x [ 1 ] ) // 2 , zip ( size , img . size ) ) ) ) return layer