How can I extract the album art from an MP3 ID3 tag?

Ted Robonson picture Ted Robonson · May 25, 2013 · Viewed 15.1k times · Source

I can successfully get the mp3 ID3 tags out of my mp3 app, using php. I am left with a huge BLOB. I'm sure this is pretty straightforward, but I just need a little help in the right direction. What I'd like to end up with is (BLOB DATA CORRECTED):

$media_year = implode($ThisFileInfo['comments_html']['year']);
$media_genre = implode($ThisFileInfo['comments_html']['genre']);
$media_jpg = [BLOBDATA];

(I know that makes no programming sense, but you get the idea. The first two lines work fine for me, but I don't know how to get the BLOBDATA from the ID3 tags and convert it to a JPG that I can display.)

In another tutorial I see this, but it doesn't connect the dots for me:

[comments] => Array
    (
        [picture] => Array
            (
                [0] => Array
                    (
                        [data] => <binary data>
                        [image_mime] => image/jpeg
                    )

            )

    )

I loathe asking readers to "do it for me" so, please forgive me. But I've tried every resource I can find. Any help is supremely appreciated.

Answer

mohammad mohsenipur picture mohammad mohsenipur · May 25, 2013

i use getid3 library for this work fine like

  <?php
  $Path="mp3 file path";
  $getID3 = new getID3;
  $OldThisFileInfo = $getID3->analyze($Path);
  if(isset($OldThisFileInfo['comments']['picture'][0])){
     $Image='data:'.$OldThisFileInfo['comments']['picture'][0]['image_mime'].';charset=utf-8;base64,'.base64_encode($OldThisFileInfo['comments']['picture'][0]['data']);
  }
  ?>
  <img id="FileImage" width="150" src="<?php echo @$Image;?>" height="150">

in this code i embedded image in to HTML with base64_encode that you can see