Using Python Image Library PIL and Google App Engine Blobstore...
This:
img = images.Image(blob_key=image)
logging.info(img.size)
self.response.head
I'am not familiair with PIL, because I use another solution from Google for serving and sizing images. Google can serve the images for you, using Google High Performance Image serving. This means:
Here is an example. You can change the =s0, to change the size. s0 returns the original size.
https://lh6.ggpht.com/1HjICy6ju1e2GIg83L0qdliUBmPHUgKV8FP3QGK8Qf2pHVBfwkpO_V38ifAPm-9m20q_3ueZzdRCYQNyDE3pmA695iaLunjE=s0
get_serving_url docs: https://developers.google.com/appengine/docs/python/images/functions
Code :
class Dynamic(db.Model): # key : name
name = db.StringProperty()
blob_ref = blobstore.BlobReferenceProperty()
serving_url = db.LinkProperty()
dyn= Dynamic.get_by_key_name(key_name)
try : # get url with size = 0
dyn.serving_url = images.get_serving_url(dyn.blob_ref, size=None, secure_url=True)
except DeadlineExceededError :
try : # sometimes this request fails, retry. This always works fine
dyn.serving_url = images.get_serving_url(dyn.blob_ref, size=None, secure_url=True)
except DeadlineExceededError :
logging.error('Image API get_serving_url deadline error after retry' %(dyn.key().name()))
return None
dyn.put()
It looks like the GAE version of PIL doesn't implement .size. Use something like this instead:
logging.info((img.width, img.height))