在android中使用phonegap时,来自gallery的图像以不同的方向显示

Lin*_*son 21 android sencha-touch android-camera cordova

我正在使用Sencha Touch和Phonegap来显示用相机拍摄的照片.通过cordova2.7.0在iphone上拍照时,图像以正确的方向绘制.但是使用三星s3,图片将倾斜-90°(仅适用于肖像图像).

navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 25, 
          destinationType: destinationType.FILE_URI,
         targetWidth: 120,
         targeHeight: 120,
          correctOrientation: true,
          sourceType: source });
Run Code Online (Sandbox Code Playgroud)

我用上面的代码拍照.肖像图像以正确的方向从相机显示器拍摄,问题仅发生在从图库中拍摄的肖像图像.有什么方法可以解决这个问题吗?

Lin*_*son 15

它只是通过添加参数encodingType解决了我的问题.现在代码看起来像

var encodingType = navigator.camera.encodingType.PNG;
var destinationType = navigator.camera.DestinationType;
var destinationType = navigator.camera.DestinationType;
var source = navigator.camera.PictureSourceType;
navigator.camera.getPicture(onPhotoURISuccess, onFail, {
  quality: 50,
  destinationType: destinationType.FILE_URI,
  encodingType: encodingType.PNG,
  targetWidth: 120,
  targeHeight: 120,
  correctOrientation: true,
  sourceType: source });
Run Code Online (Sandbox Code Playgroud)


小智 5

通过添加参数correctOrientation,它解决了我的问题。现在代码如下:

navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
destinationType: destinationType.FILE_URI,
correctOrientation: true,
sourceType: source });
}
Run Code Online (Sandbox Code Playgroud)