我想从网上获取一张图片并将其上传到亚马逊s3.在这样做的同时,我想检查图像尺寸.我在Python 3中有以下代码:
from PIL import Image
import requests
# Get response
response = requests.get(url, stream= True)
# Open image
im = Image.open(response.raw)
# Get size
size = im.size
# Upload image to s3
S3.Client.upload_fileobj(
im, # This is what i am trying to upload
AWS_BUCKET_NAME,
key,
ExtraArgs={
'ACL': 'public-read'
}
)
Run Code Online (Sandbox Code Playgroud)
问题是PIL图像对象不支持读取.我尝试上传PIL图像对象时收到以下错误im.
ValueError: Fileobj must implement read
Run Code Online (Sandbox Code Playgroud)
它只在我尝试上传'response.raw'时有效,但我需要获取图像尺寸.如何将PIL图像对象更改为类文件对象?是否有更简单的方法来获取尺寸,同时仍然能够将图像上传到s3?
所以问题是; 获取图像尺寸后如何将图像上传到s3?
我正在使用 PowerBI,并希望以“hh:mm:ss”格式显示持续时间。
我知道如何使用 DAX 将持续时间(秒、分钟、小时等)转换为“hh:mm:ss”格式的字符串,但是是否可以将此格式作为条形图中的标签获取?
在互联网上搜索似乎这是不可能的,但我无法找到明确的答案。
下面是一张图片,其中添加的红色文本显示了所需的结果(现在红色文本是静态的并且是手动添加的)。
简而言之:是否可以在 PowerBI 的图表中以“hh:mm:ss”格式显示持续时间?