使用 getid3 (id3v2) 将 APIC 写入 mp3 文件
我正在尝试使用 getid3 将 APIC 图片写入 mp3 文件。这是代码;
$cover = "/home/user/public_html/artwork/cover.jpg";
$TagData['attached_picture'][]=array(
'picturetypeid'=>2, // Cover. More: module.tag.id3v2.php -> function APICPictureTypeLookup
'description'=>'cover', // text field
'mime'=>'image/jpeg', // Mime type image
'data'=>$cover // Image data
);
但它不起作用。图像大小约为 1.5 MB。我应该调整它的大小还是什么?
我哪里错了?
谢谢
I am trying to write APIC picture to mp3 file with getid3. here is the code;
$cover = "/home/user/public_html/artwork/cover.jpg";
$TagData['attached_picture'][]=array(
'picturetypeid'=>2, // Cover. More: module.tag.id3v2.php -> function APICPictureTypeLookup
'description'=>'cover', // text field
'mime'=>'image/jpeg', // Mime type image
'data'=>$cover // Image data
);
but it doesnt work. image size is around 1.5 MB. should i resize it or sth ?
where am i wrong ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
查看他们网站上的演示: http://www.getid3.org/source /demo.write.phps
代码片段:
似乎数据键需要是图像内容,而不仅仅是图像文件的路径。
因此,在您的情况下,它应该类似于:
注意:这只是在快速浏览了演示代码之后,我还没有使用过这个库或测试过这个代码。
Looking at the demo they have on their website: http://www.getid3.org/source/demo.write.phps
snippet of code:
Seems like the data key needs to be the image content, not just the path to the image file.
So in your case, it should be something like:
Note: This is just after a quick glance at the demo code, I have not used this library or tested this code.
GetID3 需要发送数据的文件内容,而不是文件路径。然后只有它才能将它们嵌入到文件中。尝试
测试并工作:)
GetID3 needs the content of the file to be send for the data, not the file path. Then only it will be able to embed them into the file. Try
tested and working :)
我在源代码中发现了这一点:
所以图片数据必须是二进制的。
解决方案在这里:getid3 demo
I found this in the source code:
So picture data must be binary.
The solution is here: getid3 demo
这个为我工作了很长时间:
This one is working for me for long time:
对于任何只需要更新 ID3 标签(包括专辑封面)的人来说,上面的代码都可以正常工作。您需要有 getID3 库才能工作。
这个答案是基于 JacopKane 的答案,所以功劳归于他
For anyone who just needd to update their ID3 tags including the Album Art , above code works just fine You need to have getID3 library to work .
This Answer is based on JacopKane's Answer so credit goes to him