簡體   English   中英

科爾多瓦相機插件強制相機到肖像的方向

[英]Cordova Camera Plugin force orientation of camera to portrait

我正在使用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
            };

但是當我以縱向模式單擊我的文檔照片時,相機將其翻轉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
} 

屬性correctOrientation實際上沒有完全解決問題。 相反,我將encodingType更改為從PNG更改為JPG。

這個問題correctOrientation: true但在我的情況下設置correctOrientation: true相機選項中的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
)

請嘗試刪除:

correctOrientation:false

從選項。

看起來這仍然是cordova相機插件中的一個懸而未決的問題。 如果此時沒有任何解決方法可以幫助您,那么您必須等待此請求得到解決,以便您可以強制進行方向鎖定。 希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM