'How to resize filebase64?

I have an images state

const [images, setImages] = useState({
  title: "",
  media: []
})

I use react-file-base64 to convert image and store in state, limit to 5 images

<FileBase64 multiple={ true } onDone={files => {
  var newMedia = [];
  var length = files.length < 5 ? files.length : 5;
  for(let i=0; i<length; i++){
    newMedia.push(files[i].base64);          
  }
  setImage({...images, media: newMedia});
}} />

I want to resize images first, then store the resized base64 to the state, how can I do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source