Jump to content

GD Library Image Creation


ShoeLace1291

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.