Gau*_*dra 7 camera android cordova
我正在使用cordova相机插件最新在我的cordova Android应用程序中拍摄文件的照片.以下是选项:
camera.options = {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
cameraDirection: 0,
correctOrientation:false,
targetWidth:2048,
targetHeight:2048,
saveToPhotoAlbum: false
};
Run Code Online (Sandbox Code Playgroud)
但是当我以纵向模式单击我的文档照片时,相机将其翻转90度并变为风景.我不希望它翻转它.我希望它保持原样.此外,我必须指出,只有在我的手机与地面平行时才会发生这种情况,当我点击放在桌子上的文件照片时.
我在相机插件回购中找不到与此相关的任何有用的东西.有人能帮助我吗?
我只是想分享我是如何解决我的问题的,为什么在使用HTML渲染时,cordova相机强制将肖像拍摄到风景.
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL, //DATA_URL , FILE_URI
sourceType: Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPG,
mediaType: Camera.MediaType.PICTURE,
targetWidth: 500,
targetHeight: 500,
saveToPhotoAlbum: true,
correctOrientation: true //Corrects Android orientation quirks
}
Run Code Online (Sandbox Code Playgroud)
属性correctOrientation实际上没有完全解决问题.相反,我将encodingType更改为从PNG更改为JPG.
这个问题有点老了,但在我的情况下correctOrientation: true,相机选项中的设置有效。我用过cordova-plugin-camera。
const cameraOptions = {
cameraDirection: 1,
correctOrientation: true,
destinationType: 1
}
navigator.camera.getPicture(
function(path) {
// preview the image in the dom
// you need to have an <img id="img"> in your dom
document.querySelector("#img").src = path;
},
function(err) {
console.warn('an error has occured: ' + err);
}, cameraOptions
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7497 次 |
| 最近记录: |