修正对图片地址类型的判断
This commit is contained in:
@@ -37,14 +37,14 @@ from ucloud import ucloud
|
||||
# 获取图片
|
||||
def open_image_from_url(url):
|
||||
if url.startswith("http"):
|
||||
image = Image.open(url)
|
||||
else:
|
||||
# 发送HTTP请求获取图片数据
|
||||
response = requests.get(url)
|
||||
# 将响应内容转化为BytesIO对象,以便PIL处理
|
||||
image_stream = BytesIO(response.content)
|
||||
# 使用PIL的Image.open方法打开图像
|
||||
image = Image.open(image_stream)
|
||||
else:
|
||||
image = Image.open(url)
|
||||
return image
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user