onurzorluer / react-image-file-resizer

Resize Local Images with React 🌄 🌅
MIT License
317 stars 41 forks source link

how do we use the file that it returns?? #4

Closed Utsav170 closed 5 years ago

Utsav170 commented 5 years ago

how to use the file after it is resized. how can we use the uri in using the image name??

sharmad247 commented 5 years ago

Use it this way, snippet from one of my projects.

The files are stored in state as filesToStore

` let filesToStore = []

if (event.target.files)
{
  files.forEach(file=>{
    Resizer.imageFileResizer(
      file,
      500,
      500,
      'PNG',
      100,
      0,
      blob => {
        filesToStore.push(blob)
      },
      'blob'
    );
  })
  this.setState({
    filesToStore: filesToStore
  });
}`