Javascript 摄像头捕获phonegap2.9.0中的方向问题
在我的基于phonegap的应用程序中,当我以横向模式捕获图像并以纵向模式显示时,我添加了代码 正确方向:正确 但它仍然以纵向模式显示横向图像Javascript 摄像头捕获phonegap2.9.0中的方向问题,javascript,cordova,camera,screen-orientation,Javascript,Cordova,Camera,Screen Orientation,在我的基于phonegap的应用程序中,当我以横向模式捕获图像并以纵向模式显示时,我添加了代码 正确方向:正确 但它仍然以纵向模式显示横向图像 function capturePhoto() { navigator.camera.getPicture(onPhotoURISuccess,fail, { quality: 20, correctOrientation: true, destinationType:Camera.DestinationType.FILE_URI
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;
}
我应该怎么做?您是使用php上传图像服务器端吗?您可以在服务器端旋转图像是的,我正在上传图像服务器端
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 ====================*/