aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
738 stars 128 forks source link

Wrong documentation! #142

Closed zalnaRs closed 3 years ago

zalnaRs commented 3 years ago

The base64 image example is incorrect because its didn't use window.btoa(base64String) so it will don't decode properly.

blueedgetechno commented 3 years ago

For anyone wondering,

const {data,format} = result.tags.picture;
var base64String = "";
for (var i = 0; i < data.length; i++) {
     base64String += String.fromCharCode(data[i]);
}

var toReturn = "data:" + format + ";base64," + Buffer.from(base64String, 'binary').toString('base64');

return toReturn

This worked for me

aadsm commented 3 years ago

Thank you! Good catch, I should have tested before accepting the pull request 😅