2012-06-27 34 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爲了得到任何東西