Skip to content

Instantly share code, notes, and snippets.

@zzzgit
Created September 2, 2019 10:26
Show Gist options
  • Save zzzgit/1f85b94dd7ef67d670fcecd884af3052 to your computer and use it in GitHub Desktop.
Save zzzgit/1f85b94dd7ef67d670fcecd884af3052 to your computer and use it in GitHub Desktop.
let loadImage = (img, src)=>{
return new Promise((resolve, reject)=>{
img.onload = ()=>{
resolve(img)
}
img.src = src
})
}
let readImage = ()=>{
return new Promise((resolve, reject)=>{
let reader = new FileReader();
reader.onload = () => {
resolve(reader.result)
};
reader.onerror = (e) => {
reject(e)
};
reader.readAsDataURL( file )
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment