Problems in Working with GD library
Posted 13 July 2006 - 07:33 AM
I have configured my GD library with PHP 4.3.2. But when I coded my first program which are using the resources provided by GD (infact that was just a simple rectangle). I could not see the desired output instead I have seen some letters on my browser. well I passed my own PNG header at the start of my code but I dont know why I could not see the rectangle, If you know then plz reply ASAP
Posted 13 July 2006 - 10:50 AM
2: header("Content-type: image/png");
3: $image = imagecreate( 200, 300 );
4: $red = imagecolorallocate( $image, 255, 0, 0 );
Posted 13 July 2006 - 12:00 PM
Originally, you used your code without the header and your browser returned a bunch of text.
Then, you added the header and your browser returned the expected image.
You want to know why it does not work as expected without the header?
It does this as there is nothing telling the browser that it is an image, it's opening it as a plain text file I guess and unable to decode it correctly as it's not actually plain text. Therefore you add the header to tell the browser what to expect the file output to be. An alternative is to remove the header, and reference the file as an image in another script with the image tag: <img src="imagescript.php" alt="" border="0px"/>
Posted 13 July 2006 - 12:02 PM
Posted 13 July 2006 - 05:14 PM
NO NO you are not getting my point . I know the story behind sending headers I sent my own header at line 2 which you can see but still I cant see the expected result (i-e a rectangle). So If you know what the problem realy is then plz reply ASAP.
I am not creating any anti spam key image, I just only want to check whether my GD library is properly working or not.
Posted 13 July 2006 - 08:42 PM
echo('<pre>'); print_r(gd_info()); echo('</pre>');
This should give us some info about how GD is set up.
Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd
Posted 15 July 2006 - 10:39 AM
[GD Version] => bundled (2.0.12 compatible)
[FreeType Support] => 1
[FreeType Linkage] => with freetype
[T1Lib Support] =>
[GIF Read Support] => 1
[GIF Create Support] =>
[JPG Support] => 1
[PNG Support] => 1
[WBMP Support] => 1
[XBM Support] => 1
[JIS-mapped Japanese Font Support] =>
Posted 15 July 2006 - 11:19 AM
If your script is "red_rect.php" then
PS and use imagedestroy($image) at end to release memory used by image
Donations gratefully received
|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users