compress-base64

compress base64

Usage no npm install needed!

<script type="module">
  import compressBase64 from 'https://cdn.skypack.dev/compress-base64';
</script>

README

compress-base64

npm i compress-base64

or

yarn add compress-base64

Usage

import compress from 'compress-base64';

if (typeof FileReader === 'function') {
  const reader = new FileReader();
  reader.onload = event => {
    compress(event.target.result, {
      width: 400,
      type: 'image/png', // default
      max: 200, // max size
      min: 20, // min size
      quality: 0.8
    }).then(result => {
      console.log(result);
    });
  };
  reader.readAsDataURL(file);
} else {
  alert('Your browser does not support FileReader');
}