Created
December 3, 2020 12:54
-
-
Save jefBinomed/657d4e38d566985b996337ba84c08641 to your computer and use it in GitHub Desktop.
2020-fugu-image-trick
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
export function prepareImage(img) { | |
return new Promise((resolve) => { | |
fetch(img.src) | |
.then((response) => response.blob()) | |
.then((blob) => { | |
var reader = new FileReader(); | |
reader.onload = function () { | |
img.src = this.result; | |
resolve(); | |
}; // <--- `this.result` contains a base64 data URI | |
reader.readAsDataURL(blob); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment