获取exif信息

本文介绍如何获取图片exif信息。

数码相机拍摄的照片文件中包含exif信息,用于记录数码照片的属性信息和拍摄数据。这些信息可以通过@exif来获取,返回格式是JSON格式,目前支持返回的类型包括但不限于以下类型:

  • GPSLatitudeRef

  • GPSLatitude

  • GPSLongitudeRef

  • GPSLongitude

  • DateTime

  • DateTimeOriginal

  • DateTimeDigitized

  • Make

  • Model

  • Orientation

说明
  • 并非每一张图片都包含exif信息。如果原图没有exif信息,当您请求exif信息时,会返回400错误。错误码为:BadRequest,错误内容是:Image has no exif info.

  • 关于各参数的含义,请参见Exif 标准

示例

  • 没有exif信息的图片示例

    http://image-demo.img.aliyuncs.com/example.jpg@exif

    返回信息

    <Error>
    <Code>BadRequest</Code>
    <Message>Image has no exif info.</Message>
    <RequestId>64D1FF0D4D75C83534FBDE36</RequestId>
    <HostId>image-demo.img.aliyuncs.com</HostId>
    <EC>0040-00000004</EC>
    </Error>
  • 包含exif信息的图片示例

    http://image-demo.oss-cn-hangzhou.aliyuncs.com/f.jpg@exif

    返回信息

    {
        "Compression": {"value": "6"},
        "DateTime": {"value": "2015:02:11 15:38:27"},
        "ExifTag": {"value": "2212"},
        "FileSize": {"value": "23471"},
        "GPSLatitude": {"value": "0deg "},
        "GPSLatitudeRef": {"value": "North"},
        "GPSLongitude": {"value": "0deg "},
        "GPSLongitudeRef": {"value": "East"},
        "GPSMapDatum": {"value": "WGS-84"},
        "GPSTag": {"value": "4292"},
        "GPSVersionID": {"value": "2 2 0 0"},
        "ImageHeight": {"value": "333"},
        "ImageWidth": {"value": "424"},
        "JPEGInterchangeFormat": {"value": "4518"},
        "JPEGInterchangeFormatLength": {"value": "3232"},
        "Orientation": {"value": "7"},
        "ResolutionUnit": {"value": "2"},
        "Software": {"value": "Microsoft Windows Photo Viewer 6.1.7600.16385"},
        "XResolution": {"value": "96/1"},
        "YResolution": {"value": "96/1"}}