18 Feb 2021

How To | Browser Image Compression JavaScript Library


Hi there, Today I am going to use a JavaScript Image compression library. I have found it on Google. Now I'm going use it & see that how effective is this doing image compression?

How to import Browser Image Compression?

Just put CDN link to your website's head.

  <head>
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/browser-image-compression@1.0.13/dist/browser-image-compression.js"></script>
</head>
  

How to Use Browser Image Compressor?

Simple to call Browser Image Compression Api.
imageCompression function takes 2 argument.

1. File - JavaScript file object, that we get from onchange event of InputHTMLElement with type file.
2. {} - second argument is JavaScript Object.

imageCompression( File file, {} options) : Promise<File>
  



Browser/JavaScript Image Compressor

Before
After

Reaction:

No comments:

No Comments

COMMENT FROM MESSAGE