在blobstore webapp2上存储调整大小的图像

2024-04-25 16:56:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经成功地调整了图像大小使用GAE图像api现在我想再次存储在blob商店的大小调整后的图像我怎么做,请帮助。这是密码

img = images.Image(blob_key=user.profile_pic)
img.resize(width=80, height=100)
img.im_feeling_lucky()
thumbnail = img.execute_transforms(output_encoding=images.JPEG)

如果我使用此代码,它会显示调整大小的图像,但我想再次将其存储在blob store中。你知道吗

self.response.headers['Content-Type'] = 'image/jpeg'
self.response.out.write(thumbnail)

Tags: key图像imageselfapi密码imgresponse
1条回答
网友
1楼 · 发布于 2024-04-25 16:56:29

下面是获得服务url后的解决方案,我们只需在链接中传递参数即可对图像执行操作。你知道吗

img = images.Image(blob_key=user.profile_pic)
url = images.get_serving_url(user.profile_pic)        
url = url + "=s80" #if i want a thumbnail  

相关问题 更多 >

    热门问题