Spaces:
Paused
Paused
export async function convertImageToBase64(imageFileOrBlob: File | Blob): Promise<string> { | |
return new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.onload = () => { | |
if (typeof reader.result === 'string') { | |
resolve(reader.result); | |
} else { | |
reject(new Error('Failed to convert image to base64')); | |
} | |
}; | |
reader.onerror = () => { | |
reject(new Error('Error reading file or blob')); | |
}; | |
reader.readAsDataURL(imageFileOrBlob); | |
}); | |
} | |