科尔多瓦相机插件强制相机到肖像的方向

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度并变为风景.我不希望它翻转它.我希望它保持原样.此外,我必须指出,只有在我的手机与地面平行时才会发生这种情况,当我点击放在桌子上的文件照片时.

我在相机插件回购中找不到与此相关的任何有用的东西.有人能帮助我吗?

Tak*_*zar 6

我只是想分享我是如何解决我的问题的,为什么在使用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.


mot*_*oes 5

这个问题有点老了,但在我的情况下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)


Gan*_*dhi 1

看起来这仍然是 cordova 相机插件中的一个悬而未决的问题。如果此时所有解决方法都无法帮助您,那么您必须等待此请求得到解决,以便可以强制方向锁定。希望能帮助到你。