0

在我基于 phonegap 的应用程序中,当我以横向模式捕获图像时,它以纵向模式显示,我添加了代码

正确方向:真

但它仍然以纵向模式显示横向图像。这里的代码

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;
}

我应该怎么做。?

4

1 回答 1

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 ====================*/ 
于 2013-10-24T11:02:06.930 回答