我正在为我的混合应用程序开发 Ionic 框架并使用 Cordova,我在 ios 和 android 中都面临着用相机拍摄的照片的问题。当使用设备相机在纵向模式下拍摄照片时,其方向会自动更改。问题出在移动应用程序(ios 和 android)和网络(safari 和 chrome)中。我在应用程序中使用了 cordova-plugin-camera ,这是插件 ios 代码中 UIImage+CropScaleOrientation.m 文件中的代码,其中发生了 ios 的旋转
(UIImage*)imageCorrectedForCaptureOrientation:(UIImageOrientation)imageOrientation
{
float rotation_radians = 0;
bool perpendicular = false;
switch (imageOrientation) {
case UIImageOrientationUp :
rotation_radians = 0.0;
break;
case UIImageOrientationDown:
rotation_radians = M_PI; // don't be scared of radians, if you're reading this, you're good at math
break;
case UIImageOrientationRight:
rotation_radians = M_PI_2;
perpendicular = true;
break;
case UIImageOrientationLeft:
rotation_radians = -M_PI_2;
perpendicular = true;
break;
default:
break;
}
}
this is how i captured the image with device camera
选择(捕获)后,它会更改其方向,并且在 chrome(android) 和 safari(iphone) 中的 webview 中也会更改 picture orientation getting chaned in web also
这是我的第一个堆栈溢出问题,请原谅我的错误,提前致谢。
最佳答案
要在 iOS 上修复此问题:
navigator.camera.getPicture(onSuccess, onFail, {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
correctOrientation: true,
saveToPhotoAlbum: true
});
CorrectOrientation: true
指令是关键。
希望这有帮助!
关于android - 在 ionic 框架和 cordova-plugin-camera 中,用相机拍摄的照片在应用程序中逆时针旋转 90 度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36152597/