This is a discussion on GD problem within the PHP General forums, part of the PHP Programming Forums category; Hi, I´m new in PHP+GD. I have install all library (PHP4-gd2, libgd2, etc, etc, etc.) and when ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi, I´m new in PHP+GD.
I have install all library (PHP4-gd2, libgd2, etc, etc, etc.) and when I use gd functions no errors or warning are displayed, but when I use imagepng() or imagejpeg() no images are displayed in my browser, and in this place extrage symbols are displayed. You can see my bad result here: http://www.drivingconsultancy.com/ide/testi.php If somebody can helpme, I´ll be very thanks (sorry, my eglish isn´t good, I´m from Argentine) |
|
|||
|
You're outputting a blank PNG image, in binary form. In order to
display it (not that you'd see anything since it's blank), you need to output a Content-Type header first, like so: header("Content-Type: image/png"); THis will instruct the browser to treat the incoming data as image data. HTH. Ignacio Correa wrote: > Hi, I´m new in PHP+GD. > I have install all library (PHP4-gd2, libgd2, etc, etc, etc.) and when I use gd functions no errors or warning are displayed, but when I use imagepng() or imagejpeg() no images are displayed in my browser, and in this place extrage symbols are displayed. > You can see my bad result here: http://www.drivingconsultancy.com/ide/testi.php > > If somebody can helpme, I´ll be very thanks > > (sorry, my eglish isn´t good, I´m from Argentine) |
|
|||
|
ImagePNG() ouputs to the browser unless you specify the filename parameter
So those funny symbols you are seeing is the PNG file but displayed as text. To fix this you need to add a Header("Content-type: image/png"); somewhere in your PHP (preferably before ImagePNG), and it will tell your browser that the data being sent is a PNG file, not normal text/html. You may see the funny characters, or a red cross if you decide to use echo, print, print_r or similar functions, since these will output to the browser along with the PNG file, thus corrupting the image. Oh My I just noticed you have HTML in there as well :/.... If you are doing something like: echo '<html><body>'; ImagePNG(); //I want the image to appear here echo '</body></html>'; Then you will need to do: echo '<html><body>'; echo '<img src="somephpfile.php"> echo '</body></html>'; and in somephpfile.php you will have the code to generate the image including the ImagePNG(); Andrew ----- Original Message ----- From: "Ignacio Correa" <icorrea@drivingconsultancy.com> To: <php-general@lists.php.net> Sent: Tuesday, September 23, 2003 5:43 PM Subject: [php] GD problem Hi, I´m new in PHP+GD. I have install all library (PHP4-gd2, libgd2, etc, etc, etc.) and when I use gd functions no errors or warning are displayed, but when I use imagepng() or imagejpeg() no images are displayed in my browser, and in this place extrage symbols are displayed. You can see my bad result here: http://www.drivingconsultancy.com/ide/testi.php If somebody can helpme, I´ll be very thanks (sorry, my eglish isn´t good, I´m from Argentine) |
|
|||
|
It's generally a good idea to post your code so that we can see what's actually happening. Fortunately, Peter and Andrew were able to give some good tips this time, but you might not always be so lucky.
I was going to include some of my code but I fear it may just lead to further confusion. If you'd still like to see it, email me off-list and I'll attach a few examples. Edward Dudlik Becoming Digital www.becomingdigital.com ----- Original Message ----- From: "Ignacio Correa" <icorrea@drivingconsultancy.com> To: <php-general@lists.php.net> Sent: Tuesday, 23 September, 2003 12:43 Subject: [php] GD problem Hi, I´m new in PHP+GD. I have install all library (PHP4-gd2, libgd2, etc, etc, etc.) and when I use gd functions no errors or warning are displayed, but when I use imagepng() or imagejpeg() no images are displayed in my browser, and in this place extrage symbols are displayed. You can see my bad result here: http://www.drivingconsultancy.com/ide/testi.php If somebody can helpme, I´ll be very thanks (sorry, my eglish isn´t good, I´m from Argentine) |
![]() |
| Thread Tools | |
| Display Modes | |
|
|