Frontend Weekly
Published in

Frontend Weekly

Image Compression in ReactJs

Designed By Naren
  • Install the package using npm/yarn
  • Add the particular code block to your project
  • Be Amazed!

Install the package using npm/yarn

npm install compressorjs
yarn add compressorjs

Add the particular code block to your project

new Compressor(image, {      
quality: 0.8,
success: (compressedResult) => {
// compressedResult has the compressed file.
// Use the compressed file to upload the images to your server.
setCompressedFile(res)
},
});

Be Amazed!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store