我希望能够在使用谷歌应用引擎将图像 blob 保存到数据库之前调整其大小
from google.appengine.api import images
from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext import db
class ImageModel(db.Model):
image1 = blobstore.BlobReferencePropert(required = True)
class UploadImageHandler(BaseHandler, blobstore_handlers.BlobstoreUploadHandler):
def post(self):
upload_files = self.get_uploads('image1')
blob_info = upload_files[0]
blob_key = blob_info.key()
img = images.Image(blob_key = blob_key)
img.resize(width = 500, height = 500)
i = ImageModel(image1 = img)
i.put()
当然这不起作用,因为 img 不再是一个 blob。如何将图像转换回 blob,然后上传到数据库。我不想动态地提供图像并调整大小。我需要在数据库中有一个调整大小的图像。