【发布时间】:2012-05-03 00:16:18
【问题描述】:
if (file_exists($path)) {
$fileContent = id3_getImage($path);
$fileMime = id3_getMimeOfImage($path); // is set to image/jpeg
if ($fileMime != "") {
header('Content-Type: '.$fileMime);
print($fileContent);
die;
}
}
所以上面的代码在浏览器中不起作用,但是当我用图像制作图像时
$img = imagecreatefromstring($fileContent);
imagejpeg($img, 'test.jpg');die;
图像已创建,我可以在我的计算机上查看它。所以我不知道我做错了什么:(
*可能是 apache conf 中的设置吗?老实说,我对此一无所知
【问题讨论】:
-
我需要动态创建图像,因此创建图像然后将它们重定向到该路径并不是一个真正的选项。无论如何,它应该以这种方式工作
-
只需使用
imagejpeg($img, NULL); -
请解释一下 id3_getImage() 和 id3_getMimeOfImage() - 这些不是有效的运算符。
-
这是一个自定义函数,使用类 getid3 (getid3.sourceforge.net),我确信 $var 的内容是正确的,因为使用 imagejpeg 可以生成有效的图像。
-
因为我正在从音乐文件中检索封面以将其显示在网站上。