I am trying to do the exact same thing in python as what I can in JavaScript. In JavaScript I can easily draw on a canvas and then use toDataUrl(imageFormat, quality) to get the image in base64 encoded string.
Is there anything in Python that can do the exact same thing?
I have done this in Python
from PIL import Image,
im = Image.new('L', (width, height))
output = StringIO()
im.save(output, "JPEG", quality=89)
but the output is not in JPEG format. I believe that it is in PNG.
So is there anyway that I can perform the same thing as what the todataurl url does? I need this to be in jpeg and at a specific quality.
If anyone has any ideas on how to go about this, it will be much appreciated