From: epg <> Date: Sun, 29 Oct 2006 08:12:37 +0000 (+0000) Subject: Here's some demo code i whipped up to add APIC to an mp3 with taglib. X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/06ae80870fa51b8b5a4d653f5716c2180b531388 Here's some demo code i whipped up to add APIC to an mp3 with taglib. --- diff --git a/crap.cc b/crap.cc new file mode 100644 index 0000000..ed0e01d --- /dev/null +++ b/crap.cc @@ -0,0 +1,35 @@ +extern "C" { +#include +#include +#include + +#include +#include +#include + +}; + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + struct stat st; + stat(argv[2], &st); + int fd = open(argv[2], O_RDONLY); + char *m = (char *)malloc(st.st_size); + read(fd, m, st.st_size); + + TagLib::MPEG::File f(argv[1]); + TagLib::ID3v2::AttachedPictureFrame p; + p.setMimeType("image/jpeg"); + p.setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover); + TagLib::ByteVector bv; + bv.setData(m, st.st_size); + p.setPicture(bv); + TagLib::ID3v2::Tag *t = f.ID3v2Tag(true); + t->addFrame(&p); + f.save(); + return 0; +}