Closed ivioninjs closed 3 years ago
Hi! You can add the cover image to songs by modifying the APIC tag.
mp3tag.tags.v2.APIC = [{
format: 'image/jpeg', // or image/png
type: 3,
description: '',
data: bytes
}]
You can see the full list of types here. For the bytes' value, you have to read the image's buffer first then convert it to Uint8Array
:
const bytes = new Uint8Array(buffer)
Thanks a lot!
"mp3tag.tags.save is not a function" I directly copied the example that you presented
"mp3tag.tags.save is not a function" I directly copied the example that you presented
Hey, you should use mp3tag.save()
instead of mp3tag.tags.save()
"mp3tag.tags.save is not a function" I directly copied the example that you presented
Hey, you should use
mp3tag.save()
instead ofmp3tag.tags.save()
Certainly going to try as soon as I get home, thank you in advance
Alright the .save works now Next question: how do I apply the tags to a given file?
Alright the .save works now Next question: how do I apply the tags to a given file?
Saving it modifies the buffer at mp3tag.buffer
so you can use this for download.
If you are using browser, you can download the file by:
const fileBlob = new Blob([mp3tag.buffer], { type: 'audio/mpeg' })
const a = document.createElement('a')
document.body.appendChild(a)
const url = window.URL.createObjectURL(fileBlob)
a.href = url
a.download = 'filename.mp3'
a.click()
And if you're using Node, you can use it to save the file by:
const fs = require('fs')
fs.writeFileSync('filename.mp3', mp3tag.buffer)
Hello! thanks for the work you've done! It's awesome tool!
But, I didn`t understand how add image (png | jpg ) to song. Could you write simple example please?
Thanks advanced!