在离子框架中自动旋转风景到肖像

时间:2016-04-01 08:16:42

标签: angularjs ionic-framework

我正在处理一个应用程序,我在其中捕获图片,保存而不是显示。 但是当我在Landscape中拍照时,它会自动旋转并转换为肖像。

这是我的代码 ImageCapture.html

<ion-content ng-controller="ExampleController" padding="true">
  <button class="button button-full button-assertive" ng-click="photoSave()">
    Take Photo
  </button>
  <img ng-show="imgURI !== undefined" ng-src="{{imgURI}}" style="text-align: center">
</ion-content>

和我的controllers.js

.controller("ExampleController", function ($scope, $cordovaCamera) {

      $scope.photoSave = function() {
            if (window.cordova) {
              var options = { limit: 1 };
              var options = {
                quality : 75,
                destinationType : Camera.DestinationType.FILE_URI,
                sourceType : Camera.PictureSourceType.CAMERA,
                encodingType: Camera.EncodingType.JPEG,
                targetWidth: 320,
                targetHeight: 480,
                saveToPhotoAlbum: true
              };
            $cordovaCamera.getPicture(options).then(function(imagePath) {
              $scope.imgURI = imagePath;
              //Grab the file name of the photo in the temporary directory
              var currentName = imagePath.replace(/^.*[\\\/]/, '');
              //Create a new name for the photo
              var d = new Date(),
              n = d.getTime(),
              newFileName = n + ".jpg";
              //Move the file to permanent storage
              $cordovaFile.moveFile(cordova.file.tempDirectory, currentName, cordova.file.dataDirectory, newFileName).then(function(success) {
              //success.nativeURL will contain the path to the photo in permanent storage, do whatever you wish with it, e.g:
              //createPhoto(success.nativeURL);
              alert("URI:")
              $scope.imgURI =success.nativeURL;

                }, function(error) {
                  //an error occured
                  alert("Error:"+error)
                });

                }, function(error) {
                //An error occured
                alert("Error1:"+error)
                });
              }
            };
     })

为什么会发生这种情况以及我想要做些什么来处理它

编辑(详细说明): 当我在水平方向握住手机拍照时, 它捕获图像而不是自动转换图像,就好像是通过将移动设备保持在垂直位置来拍摄一样

0 个答案:

没有答案