Dear Monks,

I am currently trying to retrieve the Album Art from my MP3 files using the module MP3::Tag.

I currently have the following code after reading the documentation :

use MP3::Tag; my $mp3 = MP3::Tag->new("E:/My Music/File.mp3") or die “Can’t open Fil +e”; # Get the tags from the MP3 $mp3->get_tags; # Get the ID3 V2 tag where the picture is saved $id3v2 = $mp3->{ID3v2}; # Get the APIC frame from the Tag (The Image) which # returns a hash ref $Pic = $id3v2->get_frame("APIC"); # returns print "Content-type: image/jpeg\n\n"; print $Pic->{_Data};

If I just print $Pic->{_Data} to a text file with Binmode set, the file is not recognised as a valid image, however there is loads of binary data in the file.

My aim is for the script to return the Album Art image from a selected MP3 to the Browser.

I found the following documentation on CPAN http://search.cpan.org/~ilyaz/MP3-Tag-0.96/ID3v2-Data.pod but it only gives information on how to access the image data and not how to print it. I have searched the net and there is lots of examples on how to set the Album Art, but none to get it and print it to a browser.

Any one have any ideas / pointers?

Thanks,

Al


In reply to Get MP3 Album Art with MP3::Tag by allyc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.