Huge problem with drawing images in PHP
Posted: Thu Jun 26, 2008 4:54 pm
I'm having the weirdest problem ever here.. I don't understand what's going on. I'm trying to draw an empty rectangle, so just a border with nothing inside.
First, I drew a filled one just to see what it looks like, here's my code:
That worked fine, gave me a filled rectangle. Then I tried using just imagerectangle, here's the code:
It showed up EXACTLY the same as the filled rectangle... I thought maybe it was because it was displaying the old png file, so I deleted it off the server, and I tried it again. It still showed a filled rectangle.. Then I changed the name of the file to "graph.png", but it still created a filled rectangle.. I also tried drawing lines, using imageline, but it ALWAYS drew the original filled rectangle, no matter if I deleted the png off the server or if I changed the name of png.. What's going on???
First, I drew a filled one just to see what it looks like, here's my code:
Code: Select all
<?php
function show_black($level){
$width = 200;
$height = 20;
$image = imagecreate($width, $height);
$black = imagecolorallocate($image, 0,0,0);
//imagefilledrectangle($image, 0, 0, 99, 20, $black);
// flush image
//header("Content-type: image/png");
ImagePng($image, "picture.png") or die("wtf");
imagedestroy($image);
echo '<img src="picture.png" alt="bar" />';
}
?>
Code: Select all
<?php
function show_black($level){
$width = 200;
$height = 20;
$image = imagecreate($width, $height);
$black = imagecolorallocate($image, 0,0,0);
//imagerectangle($image, 0, 0, 200, 20, $black);
// flush image
//header("Content-type: image/png");
ImagePng($image, "picture.png") or die("wtf");
imagedestroy($image);
echo '<img src="picture.png" alt="bar" />';
}
?>