

@staticmethod
def square(imgpath, savefile, size=300, quality=98):
    '\n        Method for generate 100x100 square thumbnails.\n        '
    sqsize = (size, size)
    img = Image.open(imgpath)
    (width, height) = img.size
    if (width > height):
        delta = (width - height)
        left = int((delta / 2))
        upper = 0
        right = (height + left)
        lower = height
    else:
        delta = (height - width)
        left = 0
        upper = int((delta / 2))
        right = width
        lower = (width + upper)
    img = img.crop((left, upper, right, lower))
    img.thumbnail(sqsize, Image.ANTIALIAS)
    img.save(savefile, quality=quality)
    return File(savefile)

dataset/ETHPy150Open niwinz/niwi-web/src/niwi/photo/image.py ImageAdapter.square/original