-
-
Save AbdullahAlfaraj/0fbbc3c5829f618e2697d5cad58604ae 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 hidden or 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