-
-
Save maheshbabu/7c7717cdc40049ae8b6bfba3cb0ffa95 to your computer and use it in GitHub Desktop.
Convert a blob to an image with JavaScript (e.g. to render blob to canvas)
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
const blobToImage = (blob) => { | |
return new Promise(resolve => { | |
const url = URL.createObjectURL(blob) | |
let img = new Image() | |
img.onload = () => { | |
URL.revokeObjectURL(url) | |
resolve(img) | |
} | |
img.src = url | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment