我用的是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;
}
}使用此代码上传图像,但问题是裁剪后的图像没有保存,而是保存了原始图像。
任何解决方案,谢谢
发布于 2022-07-28 06:45:50
也许你应该上传裁剪后的图片this.croppedImage
this.UploadService.uploadFile(this.croppedImage);https://stackoverflow.com/questions/73148314
复制相似问题