【发布时间】:2016-04-28 17:14:42
【问题描述】:
我在 S3 上使用 PIL 调整图像大小,但它给出的错误是
*** AttributeError: 'bytes' object has no attribute 'tell'
这是我的代码:
image = Image.open(self.file)
resized_image = image.resize((200,200), Image.ANTIALIAS)
bucket = s3_connection()
k = Key(bucket)
filepath = '{0}/{1}'.format(filepath,filename) # filepath & filename values will be received
k.key = '{0}/{1}'.format('media', filepath)
k.set_contents_from_file(resized_image.tobytes()) <- This line is raising the above error.
【问题讨论】:
-
你不应该在
k.set_contents_from_file(file)这一行中使用self.file而不是file吗? -
@MichielOvertoom 我刚刚从我的代码中复制了主要行,self.file 是原始的 imahe,而我必须保存调整大小的图像。我将编辑我的问题
标签: python amazon-s3 python-imaging-library