目标高度在离子本机中不起作用

时间:2019-05-30 15:39:48

标签: cordova ionic3 cordova-plugins

在我的应用中,用户捕获照片或从图库中选择图像。我需要使用640 X 480调整图像大小。因此,我在camera选项中添加了targetWidth和targetHeight属性。宽度工作正常。但高度会自动更改为854px。

我尝试了这个,imageresizer插件对我不起作用。 How to resize image in Ionic 3 without quality reduce and target width and height?

takePhoto(sourceType:number) {
    console.log(sourceType);
    var options: CameraOptions = {
      quality: 100,

      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
      correctOrientation: false,
      sourceType:sourceType,
      targetWidth: 640,
      targetHeight: 480,
      allowEdit : false
    }

    this.camera.getPicture(options).then((imageData) => {
      let Image = 'data:image/jpeg;base64,' +imageData;
      this.attendance_details.image_data=Image;

      watermark([this.attendance_details.image_data, '../../assets/imgs/watermark.png'])
      .image(watermark.image.upperRight(0.5))
      .then(img => {
        this.attendance_details.image_data = img.src;
      });

    }, (err) => {
      console.log(err);
    });
  }

0 个答案:

没有答案