Created
September 2, 2019 10:26
-
-
Save zzzgit/1f85b94dd7ef67d670fcecd884af3052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let loadImage = (img, src)=>{ | |
return new Promise((resolve, reject)=>{ | |
img.onload = ()=>{ | |
resolve(img) | |
} | |
img.src = src | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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