in reply to Re: Get MP3 Album Art with MP3::Tag
in thread Get MP3 Album Art with MP3::Tag

Thanks for the reply!

I was hoping to be able to print out to a browser directly to save having to create files?

I thought that the following would achieve this, but when loaded from a Web Server the image only shows as the Red X , meaning it is corrupt.

print "Content-type: image/jpeg\n\n"; print $Pic->{_Data};

Any ideas? I will try the output to a file later on to see if I can get any further.

Alistair

Replies are listed 'Best First'.
Re^3: Get MP3 Album Art with MP3::Tag
by true (Pilgrim) on Jul 21, 2005 at 16:00 UTC
    You have to set binmode to STDOUT just like you did to the file. This example works off Windows running Apache2 and ActiveState perl 5.8
    #!C:/Perl/bin/perl use MP3::Tag; my $mp3 = MP3::Tag->new("withimage.mp3") or die "no File"; $mp3->get_tags; $id3v2 = $mp3->{ID3v2}; my $Pic = $id3v2->get_frame("APIC"); # returns print "Content-type:image/jpeg\r\n\r\n"; binmode STDOUT; print STDOUT $Pic->{_Data};
    jtrue
      Thank you so much jtrue!

      The penny finaly drops.... should have realised that I needed to set binmode on STDOUT as well.... oh well we live and learn!

      Thank you so much for your help

      Al