Skip to main content

url-to-favicon

Documentation / extractor/html-to-cite/url-to-favicon

Extract​

convertFaviconToBase64String()​

function convertFaviconToBase64String(url: string, size?: number): Promise<string>;

Defined in: extractor/html-to-cite/url-to-favicon.js:17

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​

ParameterTypeDefault valueDescription

url

string

undefined

The URL of the favicon

size?

number

16

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);