微信小程序
wx.getImageInfo
# wx.getImageInfo(Object object)
以 Promise 风格 调用:支持
小程序插件:支持,需要小程序基础库版本不低于 1.9.6
微信 Windows 版:支持
微信 Mac 版:支持
# 功能描述
获取图片信息。网络图片需先配置download域名才能生效。
# 参数
# Object object
# object.success 回调函数
# 参数
# Object res
# 示例代码
在开发者工具中预览效果
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)
}
})
}
})