N00b: gd doesnt work.

Problems with the Windows version of XAMPP, questions, comments, and anything related.

N00b: gd doesnt work.

Postby mir88i » 17. March 2011 08:42

Hi guys.. Newbie here.

I just downloaded and installed xampp on my xp machine. I'm quite new to Apache, PHP and web development in general. Although, I've done a few projects way back in college.

Anyways.. I'm trying to use GD which I understand is already bundled with PHP. I checked php.ini and found that php_gd2.dll is set as an extension (no comment out). the dll file also exists.

Im trying to run this code from http://www.php.net/manual/en/function.imagejpeg.php but I get a blank page. Am I using it wrong?
Code: Select all


// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);

// Set the content type header - in this case image/jpeg
header('Content-type: image/jpeg');

// Output the image

// Free up memory

the output html is this
Code: Select all
<body style="margin: 0px;">
<img style="-webkit-user-select: none" src="http://localhost/test/">

If I change the code to include the optional filename parameter a file is generated.
Code: Select all

Should I just generate an image and write down <img> tags to reference to that file?

Posts: 1
Joined: 17. March 2011 08:06

Re: N00b: gd doesnt work.

Postby Sharley » 17. March 2011 11:44

Code: Select all
<img style="-webkit-user-select: none" src="http://localhost/test/">
This path relates to file located here, htdocs\test\index.php - best to include the file name that contains the php code and must have a .php file extension not a .html extension.
Code: Select all
<img style="-webkit-user-select: none" src="http://localhost/test/index.php">
or use the name of the file you saved the php code to.
User avatar
AF Moderator
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 45 guests