Page 1 of 1

Cover art save

Posted: Tue Mar 08, 2016 8:21 pm
by erfiodena
Hello guys i have recently used getID3 but i can't figure how to save cover art of a m4a file in my database table in which there is a field of type BLOB. Someone can help me? Thanks.

Re: Cover art save

Posted: Tue Mar 08, 2016 8:38 pm
by James Heinrich
Cover art will be returned under [comments][picture][<key>] -- <key> will be 0 for the first entry but there may be more than one entry (for example, not an m4a file but same returned structure).

Exactly how you put the data in your table will of course depend on your database system. Assuming MySQL, and only taking the first picture if available, something like this should work:

Code: Select all

$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);

if (!empty($ThisFileInfo['comments']['picture'][0])) {
  mysql_query('INSERT INTO `tablename` (`blobfield`) VALUES ("'.mysql_real_escape_string($ThisFileInfo['comments']['picture'][0]).'")');
You'll have to supply the filename, of course, as well as fill in more of the table structure in the query (table name, you'll no doubt want some identifier so you know what file that image belongs to, etc).