GD problem

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-23-2003
Ignacio Correa
 
Posts: n/a
Default 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)
Reply With Quote
  #2 (permalink)  
Old 09-23-2003
Pete James
 
Posts: n/a
Default Re: [PHP] GD problem

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)

Reply With Quote
  #3 (permalink)  
Old 09-23-2003
Andrew Brampton
 
Posts: n/a
Default Re: [PHP] GD problem

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)
Reply With Quote
  #4 (permalink)  
Old 09-24-2003
Becoming Digital
 
Posts: n/a
Default Re: [PHP] GD problem

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)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:10 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0