ID3v2 cover art insertion with Perl?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm struggling with my flac->mp3 music library maintenance script. based
on some net articles I have used MP3::Tag to attach cover art this way

use constant HEADER => ( chr(0x0) , "image/jpeg" , chr(0x0), "");

$img = new Image::Magick;
if (! $img->Read("$flacdir/cover.jpg")) {
  $id3v2->add_frame( "APIC", HEADER, $img->ImageToBlob(magick => 'jpg'));

There is also setting

MP3::Tag->config("id3v23_unsync_size_w" => "TRUE");

See e.g.

But I get corrupted cover art images in Amarok. iTunes and Windows Media
  Player seem to work with it. MediaTomb uPnP server + PS3 doesn't find
the pictures. I'd like to get MediaTomb that uses taglib for metadata to

There are Perl bindings for taglib in Audio::TagLib in CPAN. I'm able to
generate basic ID3v1 tags with it but nothing else since the
documentation is missing/minimal and I'm far from fluent in Perl to get
the information from Audio::TagLib source code. Any pointers how to do
proper ID3v2 APIC tags with Perl would be really helpful.

I found this but it seems to generate only ID3v1 tags based on "id3v2
-l" output and there is no example of
Audio::TagLib::ID3v2::AttachedPictureFrame /


Re: ID3v2 cover art insertion with Perl?

Seppo Ingalsuo wrote:

Quoted text here. Click to load it

As response to myself this seems to work ... :^)

         my $mp3 = Audio::TagLib::MPEG::File->new($outfile);
         my $id3v2 = $mp3->ID3v2Tag(1);
         if (open(PICFILE, "$flacdir/cover.jpg")) {
             $filesize = (-s PICFILE);
             read(PICFILE, $imgdata, $filesize);
             my $imgbv = Audio::TagLib::ByteVector->new();
             my $bv = Audio::TagLib::ByteVector->new("APIC");
             my $field =
Audio::TagLib::ID3v2::AttachedPictureFrame->new($bv, "UTF8");


Re: ID3v2 cover art insertion with Perl?

Quoted text here. Click to load it

the script works fine. the cover will be displayed on windows
mediaplayer 11.. but ther is NO cover on ps3 (mediatomb).

Re: ID3v2 cover art insertion with Perl?

[A complimentary Cc of this posting was sent to

Quoted text here. Click to load it

Most software handling ID3v2 is horribly buggy.  Most creators produce
a broken MP3 file.  Most readers reject conforming ID3v2 tags.

grep docs of MP3::Tag for ITunes...

Hope this helps,

Site Timeline