url-to-favicon
ai-research-agent / extractor/html-to-cite/url-to-favicon
Extract
convertFaviconToBase64String()
function convertFaviconToBase64String(url, size?): Promise<string>
Convert a ICO/PNG favicon from URL using npm sharp into 16px image base64 string. This prevents the need for many requests to fetch for each site's favicon which can cause delays.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
|
|
| The URL of the favicon |
|
|
| Pixel size of the resized favicon |
Returns
Promise
<string
>
Base64 string of resized favicon
Throws
If there's an issue downloading or processing
Example
const base64String = await
convertFaviconToBase64String('https://www.amazon.com/favicon.ico');
console.log(base64String);