[feat] compressed data for local

This commit is contained in:
kwaroran
2023-06-23 22:19:04 +09:00
parent 40b54ad88d
commit 281e0bec63
2 changed files with 28 additions and 1 deletions

View File

@@ -20,6 +20,23 @@ export const PngMetadata = {
const encoded = encode(chunks);
return encoded
},
writeStream:(pngBuffer: Uint8Array, metadata: Record<string, string>): Buffer => {
let chunks:{
name:string
data:Uint8Array
}[] = extract(Buffer.from(pngBuffer));
chunks = chunks.filter((v) => {
return v.name.toLocaleLowerCase() !== 'text'
})
for (const key in metadata) {
const value = metadata[key];
chunks.splice(-1, 0, textKey.encode(key, value))
}
const encoded = encode(chunks);
return encoded
},
filter: (pngBuffer: Uint8Array) => {
let chunks:{
name:string