如何从MP3 ID3标签提取专辑封面? [英] How can I extract the album art from an MP3 ID3 tag?
问题描述
我可以使用php从我的mp3应用程序中成功获取mp3 ID3标签.我剩下一个巨大的BLOB.我敢肯定这很简单,但是我只需要在正确方向上提供一些帮助.我要结束的是(BLOB DATA CORRECTED):
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];
(我知道这没有编程意义,但是您明白了.前两行对我来说很好用,但是我不知道如何从ID3标签中获取BLOBDATA并将其转换为我可以显示的JPG.)
在另一个教程中,我看到了这一点,但是它并没有为我连接点:
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.
推荐答案
我使用 getid3 库来完成这项工作,例如
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">
在此代码中,我将图像嵌入到具有base64_encode
的HTML中,您可以看到
in this code i embedded image in to HTML with base64_encode
that you can see
这篇关于如何从MP3 ID3标签提取专辑封面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!