【发布时间】:2015-09-17 07:56:42
【问题描述】:
抱歉,这是个愚蠢的问题。我在php.net 上看到可以这样做。
我喜欢这个
$imagepath="smile.jpg";
$image=imagecreatefromjpeg($imagepath);
$imgheight=imagesy($image);
$color=imagecolorallocate($image,0, 153, 51);
imagestring($image, 20, 50, $imgheight-30, "this is testing", $color);
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
我的代码可以在浏览器上显示图像,当我检查它的元素时,它会显示在扩展名 .php 中调用,但我无法在其上添加文本或样式或任何内容。
例如,我只是添加更多这样的代码
<div style="height: 600px;width: 100%; position: relative; border:1px solid red">
<div>
<?php echo "Hello text"; ?>
</div>
<div style=" float: left;height: 600px;margin: 0 auto;border:1px solid yellow">
<?php
$imagepath="smile.jpg";
$image=imagecreatefromjpeg($imagepath);
$imgheight=imagesy($image);
$color=imagecolorallocate($image,0, 153, 51);
imagestring($image, 20, 50, $imgheight-30, "this is testing", $color);
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>
</div>
<div style="clear:both"></div>
任何人都可以帮我解决这个问题
谢谢
【问题讨论】:
-
"但我不能在上面添加文字或样式或任何东西。",你是什么意思?
-
我认为他的意思是该页面不支持除图片本身之外的任何其他内容。这是因为标题类型@pov 正在使用 ^^
-
浏览器上的内容只有图像,我想添加文本或样式以及任何正常页面
-
也许也发布 html 和 css 代码?这样我们就可以按照您的想法进行操作
-
您可以使用 PHP 提供图像,但您必须只提供图像。您不能使呈现的 HTML 页面显示为图像。
标签: php image file-get-contents readfile