u
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user