We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8a3792f commit 5d3ba91Copy full SHA for 5d3ba91
src/save/encodeBase64.ts
@@ -11,10 +11,12 @@ import type { ImageFormat } from './encode.js';
11
*/
12
export function encodeBase64(image: Image, format: ImageFormat) {
13
const buffer = encode(image, { format });
14
- const binaryString = new TextDecoder('latin1').decode(
15
- Uint8Array.from(buffer),
16
- );
17
-
+ const binaryArray = [];
+ for (const el of buffer) {
+ binaryArray.push(String.fromCodePoint(el));
+ }
18
+ const binaryString = binaryArray.join('');
19
const base64String = btoa(binaryString);
- return `data:image/${format};base64,${base64String}`;
20
+ const dataURL = `data:image/${format};base64,${base64String}`;
21
+ return dataURL;
22
}
0 commit comments