Skip to content

Instantly share code, notes, and snippets.

@Magoninho
Created January 9, 2022 00:56
Show Gist options
  • Save Magoninho/5ecf93a3bf39014d47f0c8b3b11206cb to your computer and use it in GitHub Desktop.
Save Magoninho/5ecf93a3bf39014d47f0c8b3b11206cb to your computer and use it in GitHub Desktop.
a nice hand function to load images
async function loadImageFromUrl(url: string): Promise<HTMLImageElement> {
return new Promise(resolve => {
const img = new Image();
img.onload = () => {
resolve(img);
}
img.src = url;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment