Skip to content

Instantly share code, notes, and snippets.

@ilyasProgrammer
Last active April 20, 2021 11:41
Show Gist options
  • Save ilyasProgrammer/3708c6260ec3fde837b1be60f678c132 to your computer and use it in GitHub Desktop.
Save ilyasProgrammer/3708c6260ec3fde837b1be60f678c132 to your computer and use it in GitHub Desktop.
PDF to Image and rotate
from pdf2image import convert_from_path, convert_from_bytes
from io import BytesIO
image = convert_from_bytes(base64.decodebytes(att.datas))[0].rotate(90, expand=True)
buffered = BytesIO()
image.save(buffered, format="JPEG")
img_str = base64.b64encode(buffered.getvalue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment