Extract cover from mp3 file
-
- User
- Posts:2
- Joined:Wed Mar 01, 2006 4:25 pm
Hello,
I made an uploader for mp3 files.
I simply want to know how to extract from the id3 tag (with PHP of course)
- the cover
- the comments
I use the function id3_get_tag in PHP but it doesn't extract the cover nor the comments.
Thanks for your help.
--
mazout
EPITA
I made an uploader for mp3 files.
I simply want to know how to extract from the id3 tag (with PHP of course)
- the cover
- the comments
I use the function id3_get_tag in PHP but it doesn't extract the cover nor the comments.
Thanks for your help.
--
mazout
EPITA
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Code: Select all
$getID3 = new getID3;
$fileinfo = $getID3->analyze($filename);
$picture = @$fileinfo['id3v2']['APIC'][0]['data']; // binary image data
$comments = @$fileinfo['id3v2']['comments']; // multi-dimensional array
-
- User
- Posts:3
- Joined:Sun Jan 21, 2007 11:29 am
HiJames Heinrich wrote:Code: Select all
$picture = @$fileinfo['id3v2']['APIC'][0]['data']; // binary image data
With this we can extract the data, but how can we show the data like a jpg image?
Thanks
-
- User
- Posts:2
- Joined:Thu Feb 01, 2007 6:46 am
-
- User
- Posts:2
- Joined:Sun Oct 28, 2007 7:17 pm
- Location:BelNet
-
- User
- Posts:2
- Joined:Sun Oct 28, 2007 7:17 pm
- Location:BelNet
I solved the problem, may be not correctly but it works! :)
in file module.tag.id3v2.php add string (1261):
Please check this bug correctly :)
Sorry for my english
in file module.tag.id3v2.php add string (1261):
Code: Select all
$parsedFrame['data'] = substr($parsedFrame['data'], 2);
Sorry for my english
-
- User
- Posts:4
- Joined:Tue Mar 11, 2008 8:16 pm
- Location:mexico
HELP PLEASE
hi, i've been traying show a cover from any mp3 and i can't get the solution.
please somebody help me, my code is:
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
thanks for the help.
please somebody help me, my code is:
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
thanks for the help.
-
- User
- Posts:4
- Joined:Tue Mar 11, 2008 8:16 pm
- Location:mexico
solved!
hi guys, i have the answer, if you need, there it is:
test1.php (here show the info of mp3)
<?php
require_once('getid3/getid3/getid3.php');
//$filename="musica/yoursong.mp3";
// include getID3() library (can be in a different directory if full path is specified)
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
echo "<img src='cover.php' width='200'>";
?>
and cover.php (here show the binary data)
<?
require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet
$getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
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 = null;
}
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) {
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime'];
} else {
$mimetype = 'image/jpeg'; // or null; depends on your needs
}
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);
}
?>
nice day!
test1.php (here show the info of mp3)
<?php
require_once('getid3/getid3/getid3.php');
//$filename="musica/yoursong.mp3";
// include getID3() library (can be in a different directory if full path is specified)
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
echo "<img src='cover.php' width='200'>";
?>
and cover.php (here show the binary data)
<?
require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet
$getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
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 = null;
}
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) {
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime'];
} else {
$mimetype = 'image/jpeg'; // or null; depends on your needs
}
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);
}
?>
nice day!
-
- User
- Posts:4
- Joined:Tue Mar 11, 2008 8:16 pm
- Location:mexico
solved!
hi guys, i have the answer, if you need, there it is:
test1.php (here show the info of mp3)
<?php
require_once('getid3/getid3/getid3.php');
//$filename="musica/yoursong.mp3";
// include getID3() library (can be in a different directory if full path is specified)
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
echo "<img src='cover.php' width='200'>";
?>
and cover.php (here show the binary data)
<?
require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet
$getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
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 = null;
}
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) {
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime'];
} else {
$mimetype = 'image/jpeg'; // or null; depends on your needs
}
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);
}
?>
nice day!
test1.php (here show the info of mp3)
<?php
require_once('getid3/getid3/getid3.php');
//$filename="musica/yoursong.mp3";
// include getID3() library (can be in a different directory if full path is specified)
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
echo "<img src='cover.php' width='200'>";
?>
and cover.php (here show the binary data)
<?
require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet
$getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
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 = null;
}
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) {
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime'];
} else {
$mimetype = 'image/jpeg'; // or null; depends on your needs
}
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);
}
?>
nice day!
-
- User
- Posts:4
- Joined:Tue Mar 11, 2008 8:16 pm
- Location:mexico
solved!
hi guys, i have the answer, if you need, there it is:
test1.php (here show the info of mp3)
<?php
require_once('getid3/getid3/getid3.php');
//$filename="musica/yoursong.mp3";
// include getID3() library (can be in a different directory if full path is specified)
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
echo "<img src='cover.php' width='200'>";
?>
and cover.php (here show the binary data)
<?
require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet
$getID3->analyze("musica/yoursong.mp3");
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 = null;
}
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) {
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime'];
} else {
$mimetype = 'image/jpeg'; // or null; depends on your needs
}
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);
}
?>
nice day!
test1.php (here show the info of mp3)
<?php
require_once('getid3/getid3/getid3.php');
//$filename="musica/yoursong.mp3";
// include getID3() library (can be in a different directory if full path is specified)
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
echo "<img src='cover.php' width='200'>";
?>
and cover.php (here show the binary data)
<?
require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet
$getID3->analyze("musica/yoursong.mp3");
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 = null;
}
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) {
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime'];
} else {
$mimetype = 'image/jpeg'; // or null; depends on your needs
}
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);
}
?>
nice day!
-
- User
- Posts:1
- Joined:Tue Mar 31, 2009 7:53 am
- Are you a spambot?:no
Re: Extract cover from mp3 file
Thanks! saulo .....
That one i want.............
That one i want.............
-
- User
- Posts:2
- Joined:Sun Jan 23, 2011 4:01 pm
- Are you a spambot?:no
Re: Extract cover from mp3 file
Hi,
Is there any way to get the spectrum(amplitude) from the mp3 files?
Thank you for the cooperation in advance.
Regards,
subham
Is there any way to get the spectrum(amplitude) from the mp3 files?
Thank you for the cooperation in advance.
Regards,
subham
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: Extract cover from mp3 file
Sure, just decode the MPEG audio, run it through a Fourier transform and there you go. That is far far far outside the scope of getID3, however.ssubham wrote:Is there any way to get the spectrum(amplitude) from the mp3 files?
-
- User
- Posts:2
- Joined:Sun Jan 23, 2011 4:01 pm
- Are you a spambot?:no
Re: Extract cover from mp3 file
thank you for the reply. Is there anyother way to get it?James Heinrich wrote:Sure, just decode the MPEG audio, run it through a Fourier transform and there you go. That is far far far outside the scope of getID3, however.ssubham wrote:Is there any way to get the spectrum(amplitude) from the mp3 files?
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: Extract cover from mp3 file
No. Anything that gives you a spectral display of the audio will be doing exactly that.