Cover art save
-
- User
- Posts:1
- Joined:Tue Mar 08, 2016 8:17 pm
- Are you a spambot?:no
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.
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: Cover art save
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: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).
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
require_once('../getid3/getid3.php');
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);
getid3_lib::CopyTagsToComments($ThisFileInfo);
if (!empty($ThisFileInfo['comments']['picture'][0])) {
mysql_query('INSERT INTO `tablename` (`blobfield`) VALUES ("'.mysql_real_escape_string($ThisFileInfo['comments']['picture'][0]).'")');
}