PNG cover art?

Locked
jcb344
User
Posts:1
Joined:Wed Jul 07, 2010 4:52 pm
Are you a spambot?:no
PNG cover art?

Post by jcb344 » Wed Jul 07, 2010 4:58 pm

I have been using code posted here to extract the cover art from an audio file. Unfortunately it does not appear to work for files embedded in the png format.

Code: Select all

<?php
require_once('getid3/getid3.php');
$file = $_GET['file']; 


$getID3 = new getID3; 
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet 
$getID3->analyze($file); 
if (isset($getID3->info['id3v2']['APIC'][0]['data'])) { 
$cover = $getID3->info['id3v2']['APIC'][0]['data']; 
} elseif (isset($getID3->info['id3v2']['PIC'][0]['data'])) { 
$cover = $getID3->info['id3v2']['PIC'][0]['data']; 
} else { 
$cover = "no_cover"; 
} 
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) { 
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime']; 
} else { 
$mimetype = 'image/jpeg'; // I have tried changing this line to $mimetype = 'image/png'; and it still does not work
} 

if (!is_null($cover)) { 
// Send file 
header("Content-Type: " . $mimetype); 

if (isset($getID3->info['id3v2']['APIC'][0]['image_bytes'])) { 
header("Content-Length: " . $getID3->info['id3v2']['APIC'][0]['image_bytes']); 
} 

echo($cover); 
} 
?>
Any ideas as to how one can extract an embedded png file?

WaldoMonster
getID3() contributor
Posts:112
Joined:Mon Apr 01, 2002 12:20 am
Location:Netherlands
Contact:

Re: PNG cover art?

Post by WaldoMonster » Fri Jul 16, 2010 7:05 pm

Also add:

Code: Select all

$getID3->option_tags_images = true;

Locked