How to load an image in python without using disk storage? How to load an image in python without using disk storage? flask flask

How to load an image in python without using disk storage?


if you don't want to store images in temporary files you can wrap URL content in stream and pass it to Image.open

import ioimport urllib.requestfrom PIL import Image# your avatar URL as exampleurl = ('https://www.gravatar.com/avatar/3341748e9b07c9854d50799e0e247fa3'       '?s=328&d=identicon&response=PG&f=1')content = urllib.request.urlopen(url).read()original_image = Image.open(io.BytesIO(content))


You could move them to a known remote location and fetch them back as needed. Using Amazon S3 or a hosted FTP service like BrickFTP are both easy. S3 is especially cheap since you only pay for what you use -- no monthly fee. Brick is a great service if you want to make access to the images as simple as possible for other applications and users but there is a minimum monthly fee.