使用相机 phonegap 拍摄的图像的未压缩大小

Uncompressed size of images taken with the camera phonegap

我正在查看我的服务器图像,这些图像是从我设备的摄像头拍摄的,但实际重量很大,准确地说是 5.4 MB,而且质量非常好。我想知道是否有某种参数要声明质量或至少文件的权重较低。

Camera.getPicture().then(function(imageURI) {
  $scope.imagen = imageURI;
  $scope.lastPhoto = imageURI;
  $scope.mostrar_form = true;
  $scope.mostrar_boton_view = false;
  google.maps.event.addDomListener(window, 'load', initialize);  
  initialize();
  document.getElementById('buton_refresh').click(); 
  $( "#buton_refresh" ).trigger( "click" );
}, function() {
  $scope.mostrar_boton_view = true;
  $ionicHistory.goBack();
}, {
  quality: 50,
  destinationType: Camera.DestinationType.FILE_URI,
  allowEdit: true,
  encodingType: Camera.EncodingType.JPEG,
  popoverOptions: CameraPopoverOptions,
  saveToPhotoAlbum: true,
  correctOrientation: true
})

函数上传图片:

$scope.publicarView = function(){
var server = URL_BASE+'addView/'+sessionService.get("user_id")+"/"+$scope.data.content+"/null/"+$scope.latitud+"/"+$scope.longitud+"/"+1;

var trustAllHosts = true;

var ftOptions = new FileUploadOptions();
ftOptions.fileKey = 'file';
ftOptions.fileName = $scope.imagen.substr($scope.imagen.lastIndexOf('/') + 1);
ftOptions.mimeType = 'image/jpeg';
ftOptions.httpMethod = 'POST';

console.log(ftOptions);

$cordovaFileTransfer.upload(encodeURI(server), $scope.imagen, ftOptions, trustAllHosts)
.then(function(result) {
  console.log(result)
}, function(err) {
  // Error
  console.log(err);
}, function (progress) {

  });
}

Cordova Camera 插件可以使用以下参数:

var options = {
    quality: 50,
    destinationType: Camera.DestinationType.NATIVE_URL,
    sourceType: Camera.PictureSourceType.CAMERA,
    allowEdit: false,
    encodingType: Camera.EncodingType.JPEG,
    targetWidth: 700,
    targetHeight: 700,
    popoverOptions: CameraPopoverOptions,
    saveToPhotoAlbum: false,
    correctOrientation: true
};

以下参数对大小有影响:

quality: 50,
targetWidth: 700,
targetHeight: 700,

在此处查看官方文档:https://github.com/apache/cordova-plugin-camera

例如,我的拍照代码类似于 ;

var options = {
        quality: 50,
        destinationType: Camera.DestinationType.NATIVE_URL,
        sourceType: Camera.PictureSourceType.CAMERA,
        allowEdit: false,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 700,
        targetHeight: 700,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: false,
        correctOrientation: true
    };

    $cordovaCamera.getPicture(options).then(function(imageData) {

        d.resolve( { "img" : imageData });

    }, function(err) {
        d.reject(err);
    });