Python 在blobstore webapp2上存储大小调整后的图像
我已经使用GAE images api成功地调整了图像的大小,现在我再次希望将调整大小的图像存储在blob store中,我如何才能做到这一点,请提供帮助。这是密码Python 在blobstore webapp2上存储大小调整后的图像,python,google-app-engine,webapp2,blobstore,Python,Google App Engine,Webapp2,Blobstore,我已经使用GAE images api成功地调整了图像的大小,现在我再次希望将调整大小的图像存储在blob store中,我如何才能做到这一点,请提供帮助。这是密码 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)
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存储中
self.response.headers['Content-Type'] = 'image/jpeg'
self.response.out.write(thumbnail)
下面是获得服务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
Blobstore不允许您编写图像。要使用Blobstore,必须上载调整大小的图像。更好的方法是使用GCS(谷歌云存储)。您可以使用blobstore API在GCS中存储blob,也可以使用Google云存储客户端库编写GCS文件。有没有办法获取已调整大小的图像的服务url。因此,我们可以显示大小调整后的图像和其他数据。此外,通过@voscausa提到的blobstore API,有关详细信息,请参阅您可以在网页中使用get\u Service\u url。此URL格式还允许动态调整大小和裁剪,但有一定的限制。查找:google.appengine.api.images.get\u service\u url