2013-10-24 150 views
0

在我的基於PhoneGap的應用程序,當我在風景拍攝圖像它在一個縱向模式顯示,我添加的代碼定位問題

correctOrientation:真

但仍須以縱向模式顯示風景圖像。此處的代碼爲

function capturePhoto() 
{ 
navigator.camera.getPicture(onPhotoURISuccess,fail, { 
    quality: 20, 
    correctOrientation: true, 
    destinationType:Camera.DestinationType.FILE_URI 
}); 
} 

function onPhotoURISuccess(imageURI) 
{ 
var options = new FileUploadOptions(); 
options.fileKey = "file"; 
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1); 
options.mimeType = "image/jpeg"; 
if(App.gvars.userpic=='1') 
{ 
document.getElementById('userpicw').src = imageURI; 
} 
if(App.gvars.userpic=='2') 
{ 
document.getElementById('productpic').src = imageURI; 
} 
if(App.gvars.userpic=='3') 
{ 
document.getElementById('userpicws').src = imageURI; 
} 
var largeImage = document.getElementById('smallImage'); 
largeImage.style.display = 'block'; 
App.gvars.userpic='0'; 
var params = new Object(); 
params.value1 = "Fastabuy"; 
options.params = params; 
options.chunkedMode = false; 
} 

我應該怎麼做。

+0

你是否使用php打亂了圖像服務器端? – Ved

+0

你可以旋轉服務器端的圖像 – Ved

+0

是的im上傳圖像服務器 – ioseve

回答

0
You can add server side for image rotate 
     $gallery_path.$vImage_name //imagepathwithname; 
     /*================= Mobile Camera Angle Rotate ====================*/ 

      $exif = exif_read_data($gallery_path.$vImage_name, 0, true); 

      if($exif['IFD0']['Orientation'] != ""){ 

       if($exif['IFD0']['Orientation'] == 6) 
        $degrees = 270; 
       else if($exif['IFD0']['Orientation'] == 3) 
        $degrees = 180; 
       else 
        $degrees = ""; 

       if($degrees != ""){ 
        // This sets the image type to .jpg but can be changed to png or gif 
        header('Content-type: image/jpeg') ; 

        // Create the canvas 
        $source = imagecreatefromjpeg($gallery_path.$vImage_name) ; 
        /* See if it failed */ 

        // Rotates the image 
        $rotate = imagerotate($source, $degrees, 0) ; 

        // Outputs a jpg image, you could change this to gif or png if needed 
        imagejpeg($rotate, $gallery_path.$vImage_name); 
       } 
      } 

     /*================= Mobile Camera Angle Rotate ====================*/