Skip to content

Instantly share code, notes, and snippets.

@schabluk
Created February 10, 2017 11:55
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save schabluk/808f8691720d3a0e0e200a333bc61ecc to your computer and use it in GitHub Desktop.
Save schabluk/808f8691720d3a0e0e200a333bc61ecc to your computer and use it in GitHub Desktop.
React-Dropzone get image width, height and base64 data
onDrop = (acceptedFiles, rejectedFiles) => {
const file = acceptedFiles.find(f => f)
const i = new Image()
i.onload = () => {
let reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => {
console.log({
src: file.preview,
width: i.width,
height: i.height,
data: reader.result
})
}
}
i.src = file.preview
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment