android - 在 ionic 框架和 cordova-plugin-camera 中,用相机拍摄的照片在应用程序中逆时针旋转 90 度

标签 android ios cordova ionic-framework cordova-plugins

我正在为我的混合应用程序开发 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/

相关文章:

java - 我可以在 android 上使用布局一次只渲染图像的一部分吗?

ios - 子类化 JSQMessages 以添加 messageID 属性

ios - Cordova 启动画面插件 iPad 横向模式问题

android - ti中pdf文件放在哪里

android - 捕获我自己的 Android 应用程序发送和接收的数据包的最佳方法是什么?

java - 在android中滚动图像

ios - XCode AddressSanitizer 结果解读

iphone - 无法使用 UILongTouchGestureRecognizer 从 MKMapView 获取坐标

ios - 本地通知phonegap ios

java - 如何让 Android 服务保持 phonegap 用户界面的活力