我希望能够调整图像Blob的大小,然后再使用Google App Engine将其保存到数据库中
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,然后上传到数据库。我不想动态提供图片并调整大小。我需要在数据库中调整图像大小。
相关分类