MCPcopy Index your code
hub / github.com/bernaferrari/FigmaToCode / imageBytesToBase64

Function imageBytesToBase64

packages/backend/src/common/images.ts:73–83  ·  view source on GitHub ↗
(bytes: Uint8Array)

Source from the content-addressed store, hash-verified

71 node.fills instanceof Array && node.fills.length > 1;
72
73const imageBytesToBase64 = (bytes: Uint8Array): string => {
74 // Convert Uint8Array to binary string
75 const binaryString = bytes.reduce((data, byte) => {
76 return data + String.fromCharCode(byte);
77 }, "");
78
79 // Encode binary string to base64
80 const b64 = btoa(binaryString);
81
82 return `data:image/png;base64,${b64}`;
83};
84
85export const exportNodeAsBase64PNG = async <T extends ExportableNode>(
86 node: AltNode<T>,

Callers 1

exportNodeAsBase64PNGFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected