我实际上是实现了一个功能,允许用户上传的照片从手机。有没有值得推荐的图片压缩插件/库?注意:它是图像压缩,而不是图像大小调整。
非常感谢
发布于 2017-05-03 21:23:10
Use the Ionic Native Camera function
有一个从0到100的质量选项。它将返回一个压缩的图像
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
});
发布于 2019-09-05 21:42:22
尝试使用ionic camera插件跟踪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
}这是targetHeight和targetWidth的魔术。:)
答案来自:Ionic image compress
https://stackoverflow.com/questions/43760112
复制相似问题