Spaces:
Sleeping
Sleeping
Download src/lib/loadImage.ts from ChrisJohnson111/test100: direct link, hf CLI and curl.
- Browser
- Download file 372 Bytes
-
https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/loadImage.ts
- Command line
-
hf download hf://spaces/ChrisJohnson111/test100/src/lib/loadImage.ts
-
curl -L -o loadImage.ts https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/loadImage.ts
372 Bytes
| export async function loadImage(image: string): Promise<HTMLImageElement> { | |
| const img = new Image(); | |
| img.src = image; | |
| const imgOnLoad = () => { | |
| return new Promise<HTMLImageElement>((resolve, reject) => { | |
| img.onload = () => { resolve(img) }; | |
| img.onerror = (err) => { reject(err) }; | |
| }) | |
| }; | |
| const loadImg = await imgOnLoad(); | |
| return loadImg | |
| } |