【发布时间】:2018-09-11 16:13:53
【问题描述】:
在我的应用中,用户可以提交将上传到 Firebase 存储的照片。我需要调整大小并压缩照片质量(不破坏它)以不占用存储空间并加快上传和检索过程。
我该怎么办?建议?
这是我的selectPhoto.ts 代码,用于选择我要上传的照片!
selectPhoto_phone(){
this.camera.getPicture({
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.camera.DestinationType.DATA_URL,
quality: 100,
encodingType: this.camera.EncodingType.PNG,
}).then(imageData => {
this.isEnabled = true;
this.myPhoto = imageData;
}, error => {
this.isEnabled = false;
console.log("ERROR -> " + JSON.stringify(error));
});
}
【问题讨论】:
-
您可以通过为质量参数提供较小的数字来要求较低的
quality。不过请注意怪癖。 github.com/apache/cordova-plugin-camera#cameraoptions-errata- -
否则您可以使用这样的基于浏览器的解决方案吗?例如,如果您使用离子。 stackoverflow.com/questions/19262141/…
-
谢谢@toskv,我会检查你的链接!
标签: angular image typescript