如何压缩离子2中的图像 [英] how to compress image in ionic 2
本文介绍了如何压缩离子2中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我实际上正在实现一项允许用户从手机上传照片的功能. 有没有推荐的图像压缩插件/库? 注意:这是图像压缩,而不是图像调整大小.
I am actually implementing a function to allow user to upload the photos from phone. Is there any image compress plugin / library to recommended? Notes: it is image compression, not image resizing.
非常感谢
推荐答案
有一个质量选项,范围从0到100.它将返回压缩的图像
There is a quality option ranging from 0-100. It will return a compressed image
const options: CameraOptions = {
quality: 50, // Try changing this
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
let base64Image = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
这篇关于如何压缩离子2中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文