I am using Flask to obtain an image using request.files.get and then manipulating it with PIL. Can I render this PIL object (as a variable in the render function) with the template's img tag's src attribute or will it return an error? In this case, what can I do to make it compatible?
CodePudding user response:
You can either
save the PIL image to a file somewhere that is served by your web server and let the
src
attribute of theimg
element point to that file, orembed the image data into the
src
value as adata:
URL (though I must confess I don’t know how well this works in practice, especially not with anything larger than thumbnail-sized images), orlet the
src
URL point to a URL which is handled by Flask and where Flask returns image data, just as it normally returns HTML text.
CodePudding user response:
No, the img tag cannot render a PIL object.