Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Adding "album art" to MP3s ...

by hoaf (Novice)
on Sep 18, 2006 at 07:41 UTC ( #573500=perlquestion: print w/ replies, xml ) Need Help??
hoaf has asked for the wisdom of the Perl Monks concerning the following question:

... is painful.

Since I'm so cheap (and bored at work, to be honest), I've taken in upon myself to write a perl mp3 parser, tagger, and calaloger (sp?).

Extracting and modifying the text tags for the MP3's is pretty easy using MP3::Tag. Heck, I can even successfully extract the images from the "APIC" tag when I create a nice, pretty web page.

Thing is, I really want to be able to replace or add a new image to certain MP3s, but I can't for the life of me figure out HOW to a) extract the relevant binary information from my album art (jpg and png format) and b) shoehorn said information into the appropriate data slot (APIC) in the MP3 ID3v2 tag.

So ... any ideas on where to look and/or how to proceed?

Thanks a bunch!

UPDATE: Thanks for the html(ish) help, McDarren!

Comment on Adding "album art" to MP3s ...
Re: Adding "album art" to MP3s ...
by McDarren (Abbot) on Sep 18, 2006 at 07:55 UTC
Re: Adding "album art" to MP3s ...
by andyford (Curate) on Oct 24, 2007 at 13:05 UTC

    #!/usr/bin/perl use warnings; use strict; use MP3::Tag; my $artfile = 'barred-spiral-NGC1512.jpg'; my $art; { local $/=undef; open my $jpg,'<', $artfile or die "Couldn't open file: $!"; binmode $jpg; $art = <$jpg>; close $jpg; } my $mp3 = MP3::Tag->new('Andrew_Ford__Cygnus_X1_Trawler.mp3'); $mp3->get_tags(); $mp3->{ID3v2}->change_frame("APIC", chr(0x0), 'image/jpeg', chr(0x0), +'Cover Art', $art); $mp3->update_tags(); $mp3->close();

    non-Perl: Andy Ford

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://573500]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2014-08-21 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (128 votes), past polls