ShoeLace1291 Posted September 11, 2011 Share Posted September 11, 2011 I am trying to create a basic image with GD library, but my browser says that the image cannot be displayed because it contains errors... I have no idea why. Here's my code: switch($_GET['case']){ case "progressbar": header('Content-Type: image/jpeg'); $barWidth = 6; $barHeight = 14; $barPadding = 2; $imageWidth = ($barWidth * 10) + (10 * $barPadding); $imageHeight = ($barHeight + ($barPadding * 2)); $img = @imagecreate($imageWidth, $imageHeight); $imgBorder = imagecolorallocate($img, 0, 0, 0); //imagefilledrectangle($img, 1, $imageHeight -1, $imageWidth - 1, $imageHeight - 1, $imgBorder); $output = "Hello, world!"; imagestring($img, 1, 4, 4, $output, $imgBorder); imagejpeg($img); imagedestroy($img); break; } I have a file called image.php that i use to create images and I use the URL image.php?case=progressbar. Quote Link to comment Share on other sites More sharing options...
voip03 Posted September 11, 2011 Share Posted September 11, 2011 With out switch() statement it work fine, but just black image. Quote Link to comment Share on other sites More sharing options...
voip03 Posted September 11, 2011 Share Posted September 11, 2011 Check this link http://php.net/manual/en/function.imagecreate.php Quote Link to comment Share on other sites More sharing options...
marcelobm Posted September 11, 2011 Share Posted September 11, 2011 I just tried your code and works fine, make sure that you are making the request passing the case=progressbar parameter or you'll get an error Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.