Initial Commit

This commit is contained in:
2025-06-27 22:45:20 -05:00
parent f35b07ecca
commit 6a5c84b609
9 changed files with 5884 additions and 2 deletions

9
src/remoteimage.ts Normal file
View File

@@ -0,0 +1,9 @@
import { fetch } from 'undici'; // Node ≥18 has global fetch; otherwise add undici
export async function fetchAndEncode(url: string) {
const res = await fetch(url);
if (!res.ok) throw new Error(`Failed to fetch image: ${url}`);
const buf = Buffer.from(await res.arrayBuffer());
const mimeType = res.headers.get('content-type') || 'image/png';
return { mimeType, data: buf.toString('base64') };
}