@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
22 lines • 878 B
text/typescript
/**
* Get image data as data-string from a URL. This is useful for embedding images
* inside of SVGs. Only JPEG and PNG images are supported.
*
* Note: This function uses `fetch` to get the image data. This means that using
* it requires the `endowment:network-access` permission.
*
* @example
* const imageData = await getImageData('https://cataas.com/cat');
* const svg = `
* <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
* <image href="${imageData}" />
* </svg>
* `;
*
* @param url - The URL to get the image data from.
* @param options - The options to use when fetching the image data. This is
* passed directly to `fetch`.
* @returns A promise that resolves to the image data as a data-string.
*/
export declare function getImageData(url: string, options?: RequestInit): Promise<string>;
//# sourceMappingURL=images.d.mts.map