def _crop_image_to_square(image):
 (width, height) = image.size
 if (width != height):
  side = (width if (width < height) else height)
  left = ((width - side) // 2)
  top = ((height - side) // 2)
  right = ((width + side) // 2)
  bottom = ((height + side) // 2)
  image = image.crop((left, top, right, bottom))
 return image

def _crop_image_to_square ( image ) : ( width , height ) = image . size if ( width != height ) : side = ( width if ( width < height ) else height ) left = ( ( width - side ) // 2 ) top = ( ( height - side ) // 2 ) right = ( ( width + side ) // 2 ) bottom = ( ( height + side ) // 2 ) image = image . crop ( ( left , top , right , bottom ) ) return image
given a pil .