python - GAE: How to get the blob-image height -


given follwing model on gae:

avatar = db.blobproperty() 

by calling image instance properties height or width (see documentation) with:

height = profile.avatar.height 

the following error thrown:

attributeerror: 'blob' object has no attribute 'height'

pil installed.

if image stored in blobproperty, data stored in datastore, , if profile entity, height can accessed as:

from google.appengine.api import images height = images.image(image_data=profile.avatar).height 

if image in blobstore, (blobstore.blobreferenceproperty in datastore), have 2 ways of doing it, better way complicated , requires getting reader blob , feeding exif reader size. easier way is:

if avatar = db.blobreferenceproperty() , profile entity, then:

from google.appengine.api import images img = images.image(blob_key=str(profile.avatar.key()))  # must execute transform access width/height img.im_feeling_lucky() # transform, otherwise gae complains.  # set quality 1 result fit in 1mb if image huge img.execute_transforms(output_encoding=images.jpeg,quality=1)  # can access img.height , img.width 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -