Andoid Chrome browser freezes when using compress
shubhpy opened this issue · comments
In my android phone of 4GB ram, when I upload an image and compress it using below code
onImageChange(event) {
let image = event.target.files[0];
this.ng2ImgMax.compressImage(image, 0.25).subscribe(
result => {
this.uploadedImage = new File([result], result.name);
this.getImagePreview(this.uploadedImage);
},
error => {
console.log('😢 Oh no!', error);
}
);
}
Referenced from this article: https://alligator.io/angular/resizing-images-in-browser-ng2-img-max/ Compress Instead of Resizing
When uploading an image of 3.5 MB, getting the compressed image of 200-500 kb. That is good but the browser is freezing for 8-15 secs.
Though this is not an issue in laptop or desktop browser.
I am considering to use this package on a Cordova application but this issue worries me. Have you found a solution for this on mobile?
Yea My colleague https://github.com/Shwshank found the solution. Ping him.
npm package : ng2-image-compress works fine for me (with some config)