troubleshooting Question

PHP: GD2 image support problem

Avatar of iDeej
iDeejFlag for Australia asked on
11 Comments1 Solution474 ViewsLast Modified:
Can you see any problems with my code below?

So far I have tried this to test whether gd2 support is set up.
echo function_exists('gd_info');       // returned true.
phpinfo();                                          // gd section had gd support enabled.

So I'm Assuming I have it installed correctly.

This is my first attempt with working with images with php so any help would be much appreciated.
	// Set up the image.
	$height = 200;
	$width = 200;
	$im = imagecreatetruecolor($width, $height);
	$white = imagecolorallocate($im, 255, 255, 255);
	$blue = imagecolorallocate($im, 0, 0, 64);
	// Draw on the Image.
	imagefill($im, 0, 0, $blue);
	imageline($im, 0, 0, $width, $height, $white);
	imagestring($im, 4, 50, 150, 'Sales', $white);
	// Output image
	Header ('Content-type: image/png');
	imagepng ($im);
	// Clean up

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros