官方文档:https://doc.quickapp.cn/featu...html
1040+
image.getExifAttributes({ uri: 'internal://cache/123.png', success: function (data) { console.log(`handling success: ${JSON.stringify(data.attributes)}`) }, fail: function (data, code) { console.log(`handling fail, code = ${code}`) } })
接口image.getExifAttributes(OBJECT)返回的Orientation就是图片的方向即旋转的值web
Orientation | 旋转角度 |
---|---|
‘1’ | 0 |
‘3’ | 180 |
‘6’ | 顺时针90 |
‘8’ | 逆时针90 |
实时判断屏幕旋转的每个角度并对照片进行矫正app
let EXIF = decodeURI(data.attributes.Orientation) console.log('EXIF', EXIF) switch (EXIF) { case '1': params[1].degree = 0; break; case '3': params[1].degree = 180; break; case '6': params[1].degree = 90; break; case '8': params[1].degree = -90;break; }
该接口可用于等比例压缩照片以及对照片进行旋转ui
image.applyOperations({ uri: 'internal://cache/123.png', operations: [ { action: 'scale', scaleX: 0.5, scaleY: 0.5 }, { action: 'crop', width: 200, height: 200 }, { action: 'rotate', degree: 90 } ], quality: 90, format: 'webp', success: function(data) { console.log(`handling success: ${data.uri}`) }, fail: function(data, code) { console.log(`handling fail, code = ${code}`) } })
//等比例压缩图片及矫正图片 compression(uri) { image.getImageInfo({ uri: uri, success: (data) => { let height = data.height let width = data.width console.log('height', height, 'width', width) console.log('压缩前', data); if (height > 1024 || width > 1024) { //须要压缩 image.getExifAttributes({ uri, success: (data) => { let params = [ { action: 'scale', scaleX: 1024 / height, scaleY: 1024 / height }, { action: 'rotate', degree: 0 } ] let EXIF = decodeURI(data.attributes.Orientation) console.log('EXIF', EXIF) switch (EXIF) { case '1': params[1].degree = 0; break; case '3': params[1].degree = 180; break; case '6': params[1].degree = 90; break; case '8': params[1].degree = 90; break; } console.log('params', params) image.applyOperations({ uri: data.uri, operations: params, quality: 90, format: 'webp', success: (data) => { console.log('压缩后', data) this.requestFn(data.uri); image.getImageInfo({ uri: data.uri, success: (data) => { let height = data.height let width = data.width console.log('height', height, 'width', width) console.log('压缩前', data); } }) }, fail: function (data, code) { console.log(`handling fail123, code = ${code}`) } }) }, fail: function (data, code) { console.log(`handling fail, code = ${code}`) } }) } else { //不须要压缩 this.requestFn(uri); } }, fail: function (data, code) { console.log(`handling fail, code = ${code}`) } }) },
1.js获取图片的EXIF,解决图片旋转问题 --https://www.cnblogs.com/suyua...
1.js两个字符串明明同样却判断显示不相等--https://blog.csdn.net/weixin_...
2.JAVASCRIPT中 , 如何把string中的空格字符%20, 接收时要真正的空格, 要如何作???-- https://zhidao.baidu.com/ques...this