假设我有以下内容:
$image = imagecreatefromjpeg($filePath);
echo imagejpeg($image);
是否可以将其显示为图像,而不需要显示标题(这会阻止其他 html 渲染?或者我必须将其拆分为多个文件吗?
最佳答案
将图像粘贴到页面中的唯一方法是将其编码为 base64,如下所示:
echo "<img src=\"data:image/jpeg;base64," . base64_encode(imagejpeg($image, true)) . "\" />";
有serious limitations in doing it like this 。相反,您应该为您的图像引用一个单独的脚本:
<img src="yourimagescript.php" />
关于php - 从没有标题的流中创建图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8128000/