我正在使用這段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