I have been struggling to compress an image client-side using Ionic 3 for the past couple of days. I have experimented with:
ng2-img-max
- encountered an error when utilizing the blue-imp-canvas-to-blob
canvas.toBlob()
method (which is a dependency of ng2-img-max
). It only provided me with information about the line where the error occurred. I believe that creating an HTMLCanvasElement
in Ionic is not feasible due to some complications with webworkers
.
Ahdin - JS library
JIC - JS library
TinyJPG - npm module
All these options presented different errors, and after investigating further, I realized that it was because the libraries/modules were not compatible with Ionic 3. In many cases, the issue seemed to be related to the HTMLCanvasElement
.
I also attempted the solution mentioned in this post - however, adjusting the quality
variable did not affect the image size.
Has anyone managed to successfully compress images client-side using Ionic 3? If so, how did you accomplish this?