# wx.getImageInfo(Object object)

with Promise style call: Supported

Mini Program plugin: Support, need to Mini Program base library version no less than 1.9.6

Get picture information. Network pictures need to configure the download domain to take effect.

# parameter

# Object object

attribute type Default values Required Introductions
src string yes Image path, support network path, local path, code package path
success function no Interface calls the successful callback function
fail function no Interface calls failed callback functions
complete function no Callback function at the end of an interface call (both successful and unsuccessful calls are executed)

# object.success callback

# parameter
# Object res
attribute type Introductions Minimum version
width number Picture original width in px. Spin is not considered.
height number Picture original height in px. Spin is not considered.
path string Local path of picture
orientation string Device orientation when taking photos 1.9.90
type string Picture format 1.9.90

res.orientation Legal value

value Introductions Minimum version
up Default direction (mobile phone horizontal holding camera), corresponding Exif to hit the target 1。 Or none orientation Information.
up-mirrored with Up, but mirror flip, corresponding to Exif to hit the target 2
down Rotate 180 degrees, corresponding Exif to hit the target 3
down-mirrored with Down, but mirror flipped, corresponding Exif to hit the target 4
left-mirrored with Left, but mirror flipped, corresponding Exif to hit the target 5
right Rotate 90 degrees clockwise, corresponding Exif to hit the target 6
right-mirrored with Right, but mirror flip, corresponding Exif to hit the target 7
left Rotate 90 degrees counterclockwise, corresponding to Exif to hit the target 8

# sample code

Preview with Developer Tool

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)
      }
    })
  }
})