# wx.getImageInfo(Object object)

> __以 [Promise 风格](/miniprogram/dev/framework/app-service/api.md#异步-API-返回-Promise) 调用__：支持
> 
> __小程序插件__：支持，需要小程序基础库版本不低于 [1.9.6](1003706)
> 
> __微信 Windows 版__：支持
> 
> __微信 Mac 版__：支持
> 
> __微信 鸿蒙 OS 版__：支持

## 功能描述

获取图片信息。网络图片需先配置download域名才能生效。

## 参数

### Object object

| 属性 | 类型 | 默认值 | 必填 | 说明 |
| ---- | ---- | ------ | -------- | ---- |
| src | string |  | 是 | 图片的路径，支持网络路径、本地路径、代码包路径 |
| success | function |  | 否 | 接口调用成功的回调函数 |
| fail | function |  | 否 | 接口调用失败的回调函数 |
| complete | function |  | 否 | 接口调用结束的回调函数（调用成功、失败都会执行） |

#### object.success 回调函数
##### 参数

###### Object res


```json
[
  {
    "属性": "width",
    "类型": "number",
    "说明": "图片原始宽度，单位px。不考虑旋转。",
    "最低版本": ""
  },
  {
    "属性": "height",
    "类型": "number",
    "说明": "图片原始高度，单位px。不考虑旋转。",
    "最低版本": ""
  },
  {
    "属性": "path",
    "类型": "string",
    "说明": "图片的本地路径",
    "最低版本": ""
  },
  {
    "属性": "orientation",
    "类型": "string",
    "说明": "[拍照时设备方向](http://sylvana.net/jpegcrop/exif_orientation.html)",
    "最低版本": "[1.9.90](1003706)",
    "子项": [
      {
        "合法值": "up",
        "说明": "默认方向（手机横持拍照），对应 Exif 中的 1。或无 orientation 信息。"
      },
      {
        "合法值": "up-mirrored",
        "说明": "同 up，但镜像翻转，对应 Exif 中的 2"
      },
      {
        "合法值": "down",
        "说明": "旋转180度，对应 Exif 中的 3"
      },
      {
        "合法值": "down-mirrored",
        "说明": "同 down，但镜像翻转，对应 Exif 中的 4"
      },
      {
        "合法值": "left-mirrored",
        "说明": "同 left，但镜像翻转，对应 Exif 中的 5"
      },
      {
        "合法值": "right",
        "说明": "顺时针旋转90度，对应 Exif 中的 6"
      },
      {
        "合法值": "right-mirrored",
        "说明": "同 right，但镜像翻转，对应 Exif 中的 7"
      },
      {
        "合法值": "left",
        "说明": "逆时针旋转90度，对应 Exif 中的 8"
      }
    ]
  },
  {
    "属性": "type",
    "类型": "string",
    "说明": "图片格式",
    "最低版本": "[1.9.90](1003706)",
    "子项": [
      {
        "合法值": "unknown",
        "说明": "未知格式"
      },
      {
        "合法值": "jpeg",
        "说明": "jpeg压缩格式"
      },
      {
        "合法值": "png",
        "说明": "png压缩格式"
      },
      {
        "合法值": "gif",
        "说明": "gif压缩格式"
      },
      {
        "合法值": "tiff",
        "说明": "tiff压缩格式"
      }
    ]
  }
]
```

## 示例代码

[在开发者工具中预览效果](https://developers.weixin.qq.com/s/Kd47Sbmr6yYu)

```js
wx.getImageInfo({
  src: 'images/a.jpg',
  success (res) {
    console.log(res.width)
    console.log(res.height)
  }
})

wx.chooseImage({
  success (res) {
    wx.getImageInfo({
      src: res.tempFilePaths[0],
      success (res) {
        console.log(res.width)
        console.log(res.height)
      }
    })
  }
})
```
