[英]Image cropper not saving cropped Image in Angular
I'm using ngx-image-cropper
我正在使用ngx-image-cropper
import { ImageCroppedEvent, ImageTransform } from 'ngx-image-cropper';
user={ ..
};
image: any = '';
croppedImage: any = '';
transform: ImageTransform = {};
scale = 1;
showCropper = false;
profilePicUpload(e): void {
this.imageChangedEvent = e;
this.image = e.target.files[0];
}
imageCropped(event: ImageCroppedEvent) {
this.user.photo = event.base64;
this.croppedImage = event.base64.substring(22);
}
imageLoaded() {
this.showCropper = true;
}
async addImg() {
if(this.image){
const path = await this.UploadService.uploadFile(this.image);
await new Promise(f => setTimeout(f, 2000));
this.user.photo = '';
this.user.photo += path;
}
}
using this code to upload image but issue is the cropped image is not saved but the original image is saved.使用此代码上传图像,但问题是未保存裁剪的图像,但保存了原始图像。
Any solution Thanks任何解决方案谢谢
Maybe you should upload the cropped image this.croppedImage
?也许您应该上传裁剪后的图像this.croppedImage
?
this.UploadService.uploadFile(this.croppedImage);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.