This commit is contained in:
seb
2026-09-27 18:32:39 +02:00
parent f9383e717f
commit 74e932c5cf
3 changed files with 71 additions and 74 deletions

View File

@@ -310,6 +310,25 @@ export async function encodeCanvasToAvif(canvas, filename = 'brandpic.avif') {
* @returns {Promise<File>}
*/
export async function downloadAndPrepareLogoAvif(url, fallbackDataUrl) {
if (url) {
try {
const resp = await fetch('/api/serper/image', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({ url }),
});
if (resp.ok) {
const avifBlob = await resp.blob();
if (avifBlob && avifBlob.size > 0) {
return new File([avifBlob], 'brandpic.avif', { type: 'image/avif' });
}
}
} catch {
// Fallback to client-side processing if /api/serper/image fails
}
}
let img;
try {
img = await downloadLogoImage(url, fallbackDataUrl);