我正在获得大量的离子图像,因此我需要对其进行编码或调整大小。我很迷路...可能吗?到目前为止,我的代码是:
base64 = 'data:image/jpeg;base64, ';
defaultAvatar = './assets/img/resources/img-avatar.png';
if (this.staffService.getStaff() === null) {
this.staffService.staffInfo().subscribe(data => {
this.staffData = this.staffService.mapStaffData(data);
this.avatar_imagen = this.staffData.image ?
this.domSanitizer.bypassSecurityTrustResourceUrl(
this.base64 + this.staffData.image
)
: this.defaultAvatar;
});
} else {
this.staffData = this.staffService.getStaff();
this.avatar_imagen = this.staffData.image ?
this.domSanitizer.bypassSecurityTrustResourceUrl(
this.base64 + this.staffData.image
)
: this.defaultAvatar;
}
使用的语言必须是Ionic或Angular。(不使用Javascript)谢谢大家。
尝试ng2-img-cropper
在上传之前使用use来调整图像的大小。此外,您可以自定义尺寸。
您可以安装名为的软件包ng2-img-cropper
:
npm install ng2-img-cropper --save
您可以在此处阅读有关ng2-img-cropper的更多信息
如果要避免使用其他软件包,则可以使用此TypeScript版本的图像调整大小。
此外,还有一些更简单的示例。但是,您还需要在某个地方创建画布,然后可以使用ViewChild
它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句