2012-06-27 38 views
5

在谷歌应用程序引擎开发环境中,我无法获取exif数据。我跟着向导从这里 https://developers.google.com/appengine/docs/python/images/imageclass谷歌应用程序引擎中的图像exif数据

我做的代码

def getResizedImage(self, image, imagemaxWidth, imagemaxHeight): 
    img = images.Image(image_data=image) 
    logging.error(img.get_original_metadata()) 

我只得到无以下。 img对象没问题,因为我可以执行img.resize等。我需要获取Exif信息。

更新:通过这样做,我能得到的元数据,

def getResizedImage(self, image, imagemaxWidth, imagemaxHeight): 
    img = images.Image(image_data=image) 
    img.rotate(0) 
    img.execute_transforms() 
    logging.error(img.get_original_metadata()) 

像文档说明我得到了很“有限”设置更准确地说这

{u'ImageLength': 480, u'ImageWidth': 640} 

显然,你得到多少在真实环境中更大的集合,我不知道为什么这不能成为开发环境的特点。这很令人沮丧。只要我能得到pyexiv2级别的exif,我没关系,但如果它只是使用PIL,那就不够好。目前PIL提供了一些exif信息。

回答

3

开发环境使用PIL来解释你所看到的。生产环境不使用PIL,并会为您提供图像中大部分标签。

+0

所以也没有在生产中使用PIL,那是一种解脱。 PIL在阅读EXIF方面严重打击。 – specialscope

0

从文档采取的get_original_metadata

 
Returns: 
    dict with string keys. If execute_transform was called with parse_metadata 
    being True, this dictionary contains information about various properties 
    of the original image, such as dimensions, color profile, and properties 
    from EXIF. 
    Even if parse_metadata was False or the images did not have any metadata, 
    the dictionary will contain a limited set of metadata, at least 
    'ImageWidth' and 'ImageLength', corresponding to the dimensions of the 
    original image. 
    It will return None, if it is called before a successful 
    execute_transfrom. 

你想传递给parse_metadata=Trueexecute_transform为了得到包括EXIF数据更多的元数据。

而且它返回None底部笔记解释为什么你不得不调用execute_transforms为了得到任何东西