<div dir="ltr">Hi,<div><br></div><div>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:</div><div>

<br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)">Music</span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">gettags</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,128)">QString</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">mediafile</span><span style="color:rgb(0,0,0)">){</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">   </span><span style="font-family:arial;color:rgb(128,0,128)">Music</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,0)">*</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,0)">music</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(0,0,0)">=</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(128,128,0)">new</span><span style="font-family:arial;color:rgb(192,192,192)"> </span><span style="font-family:arial;color:rgb(128,0,128)">Music</span><span style="font-family:arial;color:rgb(0,0,0)">();</span></pre>


</div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)">   TagLib</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">FileRef</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">file</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">mediafile</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">toUtf8</span><span style="color:rgb(0,0,0)">());</span></pre>

</div><div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,128,0)">    //get</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">covert</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">art</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">TagLib</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">ID3v2</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">Tag</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">Tag</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">file</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">file</span><span style="color:rgb(0,0,0)">(),</span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">);</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">TagLib</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">ID3v2</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">FrameList</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">list</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">Tag</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">frameListMap</span><span style="color:rgb(0,0,0)">()[</span><span style="color:rgb(0,128,0)">"APIC"</span><span style="color:rgb(0,0,0)">];</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(0,0,0)">(!</span><span style="color:rgb(0,0,0)">list</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">isEmpty</span><span style="color:rgb(0,0,0)">())</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,128)">TagLib</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">ID3v2</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">AttachedPictureFrame</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(0,0,0)">Pic</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">static_cast</span><span style="color:rgb(0,0,0)"><</span><span style="color:rgb(128,0,128)">TagLib</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">ID3v2</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">AttachedPictureFrame</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*>(</span><span style="color:rgb(0,0,0)">list</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">front</span><span style="color:rgb(0,0,0)">());</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">Pic</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">!=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">NULL</span><span style="color:rgb(0,0,0)">)</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span><span style="color:rgb(128,0,128)">std</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">string</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">artwork_s</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">Pic</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">picture</span><span style="color:rgb(0,0,0)">().</span><span style="color:rgb(0,0,0)">data</span><span style="color:rgb(0,0,0)">());</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span><span style="color:rgb(0,0,128)">qDebug</span><span style="color:rgb(0,0,0)">()</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><<</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"size:</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><<</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">Pic</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">picture</span><span style="color:rgb(0,0,0)">().</span><span style="color:rgb(0,0,0)">size</span><span style="color:rgb(0,0,0)">();</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span><span style="color:rgb(0,0,0)">music</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(128,0,0)">musicData</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(128,0,0)">artwork</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">artwork_s</span><span style="color:rgb(0,0,0)">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(0,0,0)">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">}</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">    return music;</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">}</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px">

<span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">I have checked with easytag and a front covert art is present in the file.</span></pre><pre style="margin-top:0px;margin-bottom:0px">

<br></pre><pre style="margin-top:0px;margin-bottom:0px"><font color="#000000">the qDebug() writes: </font><span style="color:rgb(181,11,11);font-size:9pt">size:  33537</span></pre>
<p style="margin:0px"><span style="font-family:monospace;font-size:9pt;color:rgb(181,11,11)"> <br></span></p><pre style="margin-top:0px;margin-bottom:0px"><font color="#000000">but when I try to show it in my qt app, I got an error message</font></pre>

<pre style="margin-top:0px;margin-bottom:0px"><p style="margin:0px"><span style="font-family:monospace;font-size:9pt;color:rgb(181,11,11)">Corrupt JPEG data: 1 extraneous bytes before marker 0xd9</span></p>
<p style="margin:0px"><span style="font-family:monospace;font-size:9pt;color:rgb(181,11,11)">JPEG datastream contains no image</span></p><p style="margin:0px"><br></p><p style="margin:0px"><font color="#000000">I don't know in which part of my code I've made a mystake.</font></p>

<p style="margin:0px"><font color="#000000"><br></font></p><p style="margin:0px"><font color="#000000"><br></font></p><p style="margin:0px"><font color="#000000">Thanks for your help,</font></p><p style="margin:0px"><font color="#000000">Audric</font></p>

</pre></div></div>