from PIL import Image
def format_image(path):
image = Image.open(path)
image = image.rotate(-90, expand=True)
new_image = Image.new('1', (512, image.height), 1)
new_image.paste(image, (0, 0))
return new_image
#format_image("static/text/text.png").save("output.png")