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. Link to comment https://forums.phpfreaks.com/topic/246893-gd-library-image-creation/ 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. Link to comment https://forums.phpfreaks.com/topic/246893-gd-library-image-creation/#findComment-1267929 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 Link to comment https://forums.phpfreaks.com/topic/246893-gd-library-image-creation/#findComment-1267931 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 Link to comment https://forums.phpfreaks.com/topic/246893-gd-library-image-creation/#findComment-1267935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.