Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在拍照或使用ionic 5从库中选择照片后操作图像(裁剪和调整大小)_Javascript_Html_Angular_Ionic Framework - Fatal编程技术网

Javascript 如何在拍照或使用ionic 5从库中选择照片后操作图像(裁剪和调整大小)

Javascript 如何在拍照或使用ionic 5从库中选择照片后操作图像(裁剪和调整大小),javascript,html,angular,ionic-framework,Javascript,Html,Angular,Ionic Framework,基本上,我需要操纵我选择的图片,然后才能在HTML页面中查看它。 到目前为止,我所做的是操作表,它有两个选项“加载图像”或“拾取图像”: async selectImage() { const actionSheet = await this.actionSheetController.create({ header: 'Select Image source', buttons: [{ text: 'Load from Library', handler: () => {

基本上,我需要操纵我选择的图片,然后才能在HTML页面中查看它。 到目前为止,我所做的是操作表,它有两个选项“加载图像”或“拾取图像”:

async selectImage() {
const actionSheet = await this.actionSheetController.create({
header: 'Select Image source',
buttons: [{
  text: 'Load from Library',
  handler: () => {
    this.pickImage(this.camera.PictureSourceType.PHOTOLIBRARY);
  }
},
{
  text: 'Use Camera',
  handler: () => {
    this.pickImage(this.camera.PictureSourceType.CAMERA);
  }
},
{
  text: 'Cancel',
  role: 'cancel'
}
]
});
}
这是pickImage函数

pickImage(sourceType) {
const options: CameraOptions = {
quality: 100,
sourceType,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation: true,
};
this.camera.getPicture(options)
.then((imageData) => {
this.crop.crop(imageData, {quality: 100 });
this.serviceps.logo = 'data:image/jpeg;base64,' + imageData;
}, error => console.error('Error cropping image', error));

}

那么现在我如何在选择图像之后添加裁剪和编辑图像呢?从昨天开始我就一直在尝试,但是我做不到。

使用这个插件:是的,我确实用过,但它对我不起作用。谢谢,这是因为您正在获得
base64
,并且此插件支持
文件URI
。将相机代码从
this.camera.DestinationType.DATA\u URL
更改为
this.camera.DestinationType.FILE\u URI
。同时降低图像质量。质量:100=>质量:50它会降低您的图像质量size@HassanAli它不起作用了:'((((((使用此插件:是的,我确实使用了它,但它对我不起作用。谢谢,因为您正在使用
base64
,此插件支持
文件URI
。将您的相机代码从
this.camera.DestinationType.DATA\u URL
更改为
this.camera.DestinationType.FILE\u URI
。同时降低图像质量。质量:100=>质量:50它会降低你的形象size@HassanAli它不起作用了:'((((((