谷歌应用引擎中的图像exif数据

时间:2012-06-27 07:52:26

标签: python google-app-engine exif

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

我在代码

中完成了以下操作
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信息。

2 个答案:

答案 0 :(得分:3)

开发环境使用PIL来解释你所看到的内容。生产环境不使用PIL,并且会为您提供图像中的大多数标记。

答案 1 :(得分: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=True传递给execute_transform,以获取更多元数据,包括exif数据。

关于它返回None的底部注释解释了为什么你必须致电execute_transforms才能获得任何回报