covert art data and size issue
Lukáš Lalinský
lalinsky at gmail.com
Mon Apr 28 10:06:28 UTC 2014
std::string artwork_s(Pic->picture().data());
This code uses the NULL byte to determine the size, which JPEG is very
likely to have somewhere in the middle. You need to explicitly set it. Use
this string constructor instead: string (const char* s, size_t n);
Lukas
On Mon, Apr 28, 2014 at 10:47 AM, Audric Ackermann <audric.bilb at gmail.com>wrote:
> Hi,
>
> I need to get metadata from audio files and found taglib. It works fine
> with artist, album, title,... but I have some problems with covert art.
> Here is my code to extract it:
>
> Music* gettags(QString mediafile){
>
> Music * music = new Music();
>
> TagLib::FileRef file(mediafile.toUtf8());
>
>
> //get covert art
>
> TagLib::ID3v2::Tag Tag(file.file(),0);
>
> TagLib::ID3v2::FrameList list = Tag.frameListMap()["APIC"];
>
>
> if(!list.isEmpty()) {
>
> TagLib::ID3v2::AttachedPictureFrame *Pic = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(list.front());
>
>
> if(Pic != NULL) {
>
> std::string artwork_s(Pic->picture().data());
>
> qDebug() << "size: " << Pic->picture().size();
>
> music->musicData.artwork = artwork_s;
>
>
> }
>
> }
>
> return music;
>
> }
>
>
>
> I have checked with easytag and a front covert art is present in the file.
>
>
>
> the qDebug() writes: size: 33537
>
>
>
> but when I try to show it in my qt app, I got an error message
>
> Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
>
> JPEG datastream contains no image
>
>
> I don't know in which part of my code I've made a mystake.
>
>
>
>
> Thanks for your help,
>
> Audric
>
>
>
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20140428/1508047a/attachment.html>
More information about the taglib-devel
mailing list