bergben / ng2-img-max

Angular 2 module to resize images down to a certain width and height or to reduce the quality to fit a certain maximal filesize - all in the browser.
MIT License
83 stars 46 forks source link

Andoid Chrome browser freezes when using compress #32

Open shubhpy opened 6 years ago

shubhpy commented 6 years ago

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.

kctang commented 6 years ago

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?

shubhpy commented 6 years ago

Yea My colleague https://github.com/Shwshank found the solution. Ping him.

Shwshank commented 6 years ago

npm package : ng2-image-compress works fine for me (with some config)