我已经用Ionic 3压缩了2天的图像客户端。我试过:
ng2-img-max -在使用blue-imp-canvas-to-blob canvas.toBlob()方法(ng2-img-max的依赖项)时引发错误。它只是告诉我错误发生在哪一行。我想我读过用Ionic语言创建HTMLCanvasElement是不可能的--这与webworkers有关。
Ahdin - JS library JIC - JS library TinyJPG - npm module
所有这些都带来了各种各样的错误,在研究它们之后,我确定了its,因为库/模块与Ionic 3不兼容。我认为这在很多时候是HTMLCanvasElement的一个问题。
我尝试了这问题中的建议--但更改quality变量并不会改变图像的大小。
是否有人成功地使用Ionic 3压缩客户端的图像?你是怎么做到的?
发布于 2017-07-23 15:26:45
尝试使用CameraOptions跟踪照相机插件。
const options: CameraOptions = {
quality: 20,
targetWidth: 600,
targetHeight: 600,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.PNG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
allowEdit: true //may not work with some deices
}发布于 2019-06-18 05:58:36
我正在使用ngx-图像压缩
import { NgxImageCompressService } from "ngx-image-compress";
constructor(public imageCompress: NgxImageCompressService) { }
private compressImage() {
this.imageCompress.compressFile(data, '', 50, 50).then(result => {
this.imageData = result;
})
}播放选项,或循环压缩过程以获得所需的结果:)
https://stackoverflow.com/questions/45266483
复制相似问题