def resize(image, size):
        output = BytesIO()
        back = im.new('RGBA', size, (0,0,0,0))
        image.thumbnail(size, im.ANTIALIAS)
        offset = [0,0]
        if image.size[0] >= image.size[1]:
            offset[1] = int(back.size[1]/2-image.size[1]/2)
        else:
            offset[0] = int(back.size[0]/2-image.size[0]/2)
        back.paste(image, tuple(offset))
        back.save(output, image.format)
        contents = output.getvalue()
        output.close()
        return contents
dataset/ETHPy150Open jyapayne/Web2Executable/image_utils.py/resize/original