[ID3 Dev] Embedding Cover Art

Hammond, Tony T.Hammond at nature.com
Tue Nov 22 09:09:33 PST 2005


Hi Guys:
 
I know this is probably a FAQ somewhere but couldn't find it, but have been
tearing my hair out with Perl MP3::Tag module - great stuff, but for this
one detail: embedding a PNG file for cover art into an MP3. Code I have is:
 
###
 
my $mp3 = MP3::Tag->new($mp3_file);
$mp3->get_tags();
my $id3v2 = $mp3->{'ID3v2'} if exists $mp3->{'ID3v2'};
 
my $cover;
open F, $png_file;
my $filesize = (-s F);
binmode F;
read(F, $cover, $filesize);
close F;
 
$id3v2->add_frame('APIC', chr(0x0), 'image/png', chr(0x3), 'Cover art',
$cover);
 
###
 
I seem to just get a corrupted frame which then corrupts the other frames.
PNG file seems to be good as I write a copy out to disk and check that.
 
Any help very gratefully received.
 
Cheers,
 
Tony
 
 
 
  
 
 

********************************************************************************   
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
not the original intended recipient. If you have received this e-mail in error
please inform the sender and delete it from your mailbox or any other storage
mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
liability for any statements made which are clearly the sender's own and not
expressly made on behalf of Macmillan Publishers Limited or one of its agents.
Please note that neither Macmillan Publishers Limited nor any of its agents
accept any responsibility for viruses that may be contained in this e-mail or
its attachments and it is your responsibility to scan the e-mail and 
attachments (if any). No contracts may be concluded on behalf of Macmillan 
Publishers Limited or its agents by means of e-mail communication. Macmillan 
Publishers Limited Registered in England and Wales with registered number 785998 
Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS   
********************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.id3.org/pipermail/id3v2/attachments/20051122/5481442b/attachment.html>


More information about the ID3v2 mailing list