@staticmethod
    def square(imgpath, savefile, size=300, quality=98):
        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)
Wait and check for the power state change.
dataset/ETHPy150Open niwinz/niwi-web/src/niwi/photo/image.py/ImageAdapter.square--crossover with--dataset/ETHPy150Open openstack/ironic/ironic/drivers/modules/ucs/power.py/_wait_for_state_change