impeccable_nice Posted July 13, 2006 Share Posted July 13, 2006 hello, 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 Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/ Share on other sites More sharing options...
zq29 Posted July 13, 2006 Share Posted July 13, 2006 Posting up your code might be a good idea ;) Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-57140 Share on other sites More sharing options...
impeccable_nice Posted July 13, 2006 Author Share Posted July 13, 2006 1: <?php2: header("Content-type: image/png");3: $image = imagecreate( 200, 300 );4: $red = imagecolorallocate( $image, 255, 0, 0 );5: imagepng($image);6: ?> Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-57221 Share on other sites More sharing options...
zq29 Posted July 13, 2006 Share Posted July 13, 2006 Ok, reading back through your original post, I'm not following you 100%. So lets clear this up...Originally, you used your code [i]without[/i] 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"/> Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-57254 Share on other sites More sharing options...
brown2005 Posted July 13, 2006 Share Posted July 13, 2006 wat are u trying to do, create a validation image or something? Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-57255 Share on other sites More sharing options...
impeccable_nice Posted July 13, 2006 Author Share Posted July 13, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-57450 Share on other sites More sharing options...
kenrbnsn Posted July 13, 2006 Share Posted July 13, 2006 How are you invoking the script?Ken Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-57462 Share on other sites More sharing options...
ShogunWarrior Posted July 13, 2006 Share Posted July 13, 2006 Put this in a page, and give us the result.[code]echo('<pre>');print_r(gd_info());echo('</pre>');[/code]This should give us some info about how GD is set up. Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-57576 Share on other sites More sharing options...
impeccable_nice Posted July 15, 2006 Author Share Posted July 15, 2006 Array( [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] =>) Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-58464 Share on other sites More sharing options...
Barand Posted July 15, 2006 Share Posted July 15, 2006 Put it on the page with an an IMG tag, just as would any other image.If your script is "red_rect.php" then<img src='red_rect.php'>PS and use imagedestroy($image) at end to release memory used by image Quote Link to comment https://forums.phpfreaks.com/topic/14451-problems-in-working-with-gd-library/#findComment-58470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.