Merge pull request #1746 from Makosful/release
Iterate over textChunks to find character data
This commit is contained in:
commit
5185752662
|
@ -18,11 +18,18 @@ const parse = async (cardUrl, format) => {
|
|||
});
|
||||
|
||||
if (textChunks.length === 0) {
|
||||
console.error('PNG metadata does not contain any text chunks.');
|
||||
throw new Error('No PNG metadata.');
|
||||
}
|
||||
|
||||
let index = textChunks.findIndex((chunk) => chunk.keyword.toLowerCase() == 'chara');
|
||||
|
||||
if (index === -1) {
|
||||
console.error('PNG metadata does not contain any character data.');
|
||||
throw new Error('No PNG metadata.');
|
||||
}
|
||||
|
||||
return Buffer.from(textChunks[0].text, 'base64').toString('utf8');
|
||||
return Buffer.from(textChunks[index].text, 'base64').toString('utf8');
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue