我正在使用这段PHP代码来创建和旋转图像。它可以完美的工作,当我只是打电话给它img.php它躺在英寸在php中创建图像只有在页面
但是,如果我尝试在其他任何内容包括img.php,或只包括片段在另一页(在同一台服务器上),它只显示我有很多问号而不是图像。
我的感觉是问题与发送的标题有关,但老实说我不知道。
任何建议如何使这个有用的,所以它可以被包含在另一个页面,仍然工作?
<?php
header("Content-type: image/jpeg");
// option one
// create a 250*77 image
$im = imagecreate(250, 77);
// option two
// creating a image from jpeg
$im = @imagecreatefromjpeg("images/test.jpg")
or die("Cannot Initialize new GD image stream");
// white background and black text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 0);
//create the text
$skrivetekst = date('d.m.Y');
$skrivetekst2 = date('H:i:s');
// write the string at the top left
imagestring($im, 5, 0, 0, $skrivetekst, $textcolor);
imagestring($im, 5, 0, 20, $skrivetekst2, $textcolor);
///Rotate the image
$rotate = imagerotate($im, 90, 0);
// output the image
// Output
imagejpeg($rotate);
ImageDestroy ($rotate);
?>
问候特勒尔斯
你是什么意思的“很多问号”?图像无法加载? Firebug的网页标签说明它是否被加载? – 2010-09-08 17:25:26
在这里您可以看到问题标记:http://tm-design.dk/kontrabande/ – Troels 2010-09-08 17:32:43
或probl better,screendumb:http://tm-design.dk/kontrabande/problem.png – Troels 2010-09-08 17:43:27