Если изображение хранится в BlobProperty, то данные сохраняются в хранилище данных, и если profile
является вашей сущностью, то к высоте можно получить доступ как:
from google.appengine.api import images
height = images.Image(image_data=profile.avatar).height
Если изображениенаходится в blobstore, (blobstore.BlobReferenceProperty в хранилище данных), тогда у вас есть 2 способа сделать это, лучший способ сложнее и требует получения ридера для большого двоичного объекта и подачи его в exif-ридер для получения размера.Более простой способ:
, если avatar = db.BlobReferenceProperty()
и profile
является вашей сущностью, то:
from google.appengine.api import images
img = images.Image(blob_key=str(profile.avatar.key()))
# we must execute a transform to access the width/height
img.im_feeling_lucky() # do a transform, otherwise GAE complains.
# set quality to 1 so the result will fit in 1MB if the image is huge
img.execute_transforms(output_encoding=images.JPEG,quality=1)
# now you can access img.height and img.width