2012-02-19 79 views
6

不知道會是什麼造成這一點,但是當我通過FileTransfer()某些圖片上傳到我的遠程服務器,圖像有時會出現要麼橫盤或倒置。但是,當我在iPhone上本地查看圖像時,它們以正確的方式定位。圖像通過PhoneGap的(IOS)上載後側身/顛倒了

例如,當我選擇這樣要上傳的圖片:

它會變成這樣:http://sharefa.st/view/EWdW1Z4G8r8z

我現在用的是本地路徑來傳輸文件,所以不理解爲什麼圖像會「隨機」旋轉。

這裏是我的上傳功能:

function uploadPhoto() { 

    var options = new FileUploadOptions(); 
    options.fileKey = 'file'; 
    options.fileName = imgURI.substr(imgURI.lastIndexOf('/')+1); 
    options.mimeType = 'image/jpeg'; 

    var params = new Object(); 

    if(logged_in == true) { 

     params.unique_id = app_unique_id; 
     params.secret_key = user_secret_key; 

    } 

    options.params = params; 

    loadingStart(); 

    var ft = new FileTransfer(); 

    ft.upload(imgURI, 'http://' + remote_server + '/API/upload', uploadDetails, fail, options); 

} 

imgURI值如下:

file://localhost/var/mobile/Applications/<snip>/tmp/photo_015.jpg 

任何有識之士的讚賞。

+1

我也有iOS上同樣的問題,我會盡快鑽研它。 – 2012-02-19 22:18:29

回答

15

由於Humanoidism指出,這個問題實際上與iPhone,並存儲圖像的方式,我能想出一個solutuion。

要以正確的方向上傳照片,您必須將correctOrientation設置添加到getPicture()中的選項數組中,並將其設置爲true

這裏有兩個例子:

function capturePhoto() { 

    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 30, correctOrientation: true }); 

} 

function getPhoto(source) { 

    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 30, 
    destinationType: destinationType.FILE_URI, 
    sourceType: source, 
    correctOrientation: true }); 

} 
+0

我使用的科爾多瓦3.5.0。我將''correctOrientation到TRUE;但圖像翻轉與前置攝像頭,在Android :( – Vishnu 2014-10-27 10:39:36

1

問題不是PhoneGap的,但iPhone。 iPhone被設計爲用作寬鏡頭相機。如果您打算在桌面上查看照片或拍攝視頻,請將手機側身翻過來。您的手機會正確顯示它們,因爲它「知道」您如何拍攝它們,但您正在查看的計算機不是。

,你可以做些什麼來防止這種情況是上傳前旋轉圖片。這不是一個建議的修復方法,但至少臺式機上的人可以看到它。雖然在iPhone上觀看時,他們,他們會被旋轉 - 也許對羯羊或不移動設備將圖像旋轉可以派上用場的支票 - 但仍然再次,不建議使用。