0
我有兩個網站(同一臺服務器),其中一個簡單的矩形使用ImagickDraw繪製,它在一個做工精細,未能在第二位的錯誤 -ImagickDraw矩形 - 圖像無法顯示錯誤
圖像「 http://site_name/imagick/img?method=placeholder¶ms=258,150「無法顯示,因爲它包含錯誤。
基本上什麼代碼所做的就是它取method
並params
從URL(高度&寬度)和繪製圖像。
$params = explode(",", $_GET["params"]);
$width = (int) $params[0]; //258
$height = (int) $params[1]; //150
if ($method == "placeholder") { //This is true $method is set to placeholder
$image = new Imagick();
$image->newImage($width, $height, "#707070");
$image->setImageFormat("png");
$x = 0;
$y = 0;
$size = 40;
$draw = new ImagickDraw();
while ($y < $height) {
$draw->setFillColor("#808080");
$points = array(
array("x" => $x, "y" => $y),
array("x" => $x + $size, "y" => $y),
array("x" => $x + $size * 2, "y" => $y + $size),
array("x" => $x + $size * 2, "y" => $y + $size * 2),
);
$draw->polygon($points);
$points = array(
array("x" => $x, "y" => $y + $size),
array("x" => $x + $size, "y" => $y + $size * 2),
array("x" => $x, "y" => $y + $size * 2),
);
$draw->polygon($points);
$x += $size * 2;
if ($x > $width) {
$x = 0;
$y += $size * 2;
}
}
$draw->setFillColor("#B0B0B0");
$draw->setFontSize($width/5);
$draw->setFontWeight(800);
$draw->setGravity(Imagick::GRAVITY_CENTER);
$draw->annotation(0, 0, $width . " x " . $height);
$image->drawImage($draw);
header("Content-type: image/png");
echo $image;
}
我檢查頭之前的緩衝區,它是空的也試過ob_clean()
- 仍然無法正常工作。
檢查文件中的空白,因爲我發現它會影響圖像文件 - 但沒有空白。
任何想法可能是錯誤在這裏或無論如何跟蹤錯誤?
也許檢查服務器日誌中是否有錯誤,或註釋掉'header'並查看瀏覽器中返回的內容。 – emcconville
感謝您的評論,但錯誤是空白本身,發佈爲答案。 – jitendrapurohit