changes withou consider zlib

This commit is contained in:
Gabriel Gomes 2025-03-31 01:22:09 +01:00
parent a89f353f5b
commit a8b9295067
2 changed files with 23 additions and 18 deletions

View file

@ -77,19 +77,20 @@ export const encodePngMetadata = async ({
}), }),
); );
let metadataChunk; let metadataChunk: TEXtChunk | ITXtChunk;
try { try {
if (useITXt) { if (useITXt) {
metadataChunk = iTXt.encodeSync( metadataChunk = {
MIME_TYPES.excalidraw, name: "iTXt",
encodedData, data: iTXt.encodeSync({
{ keyword: MIME_TYPES.excalidraw,
compressed: true, text: encodedData,
compressedMethod: 0, compressionFlag: true,
language: "en", compressionMethod: 0,
translated: "" languageTag: "en",
} translatedKeyword: ""
); })
};
} else { } else {
throw new Error("Fallback to tEXt"); throw new Error("Fallback to tEXt");
} }

View file

@ -43,11 +43,15 @@ declare module "png-chunk-text" {
function decode(data: Uint8Array): { keyword: string; text: string }; function decode(data: Uint8Array): { keyword: string; text: string };
} }
declare module "png-chunk-itxt" { declare module "png-chunk-itxt" {
function encodeSync( function encodeSync(options: {
keyword: string, keyword: string;
text: string, text: string;
options?: { compressed?: boolean; compressedMethod: number; language?: string; translated?: string }, compressionFlag?: boolean;
): { name: "iTXt"; data: Uint8Array }; compressionMethod?: number;
languageTag?: string;
translatedKeyword?: string;
}): Uint8Array;
function decodeSync(data: Uint8Array): { function decodeSync(data: Uint8Array): {
keyword: string; keyword: string;
text: string; text: string;