ai-comic-factory / src /lib /loadImage.ts
jbilcke-hf's picture
jbilcke-hf HF staff
adding some counter measures to reduce the pressure on the server
cb3fdda
raw
history blame
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
}