def load_image(in_image):
""" Load an image, returns PIL.Image. """
# if the path appears to be an URL
if urlparse(in_image).scheme in ('http', 'https',):
# set up the byte stream
img_stream = BytesIO(request.urlopen(in_image).read())
# and read in as PIL image
img = Image.open(img_stream)
else:
# else use it as local file path
img = Image.open(in_image)
return img
评论列表
文章目录