Re: Image header problems
| From: | Hugh Danaher | Date: | Fri, 10 Aug 2001 19:07:20 +0000 |
| Subject: | Re: Image header problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62197@lists.php.net to get a copy of this message | ||
When I first posted my question I had 2 blank lines above the <?php call,
and those were the two lines I needed to remove. Thank you again though for
responding to my question. Without experienced programmers like you, us
newbies would still be in the dark.
Now my next hurtle: I can generate a .jpg image, I just can't seem to get it
inserted into a page that is otherwise php generated text and tables. I
think I'll get it eventually, but for now it is a puzzlement.
Hugh
----- Original Message -----
From: Maxim Maletsky <maxim@japaninc.com>
To: 'Hugh Danaher' <hdanaher@earthlink.net>
Cc: Php-General <php-general@lists.php.net>
Sent: Friday, August 10, 2001 1:46 AM
Subject: RE: [PHP] Image header problems
you didn't examine my code well enough.
line 1 is where PHP starts... <?php
line 2 and 3 are empty and will cause nothing...
line 4 is commented...
Sincerely,
Maxim Maletsky
Founder, Chief Developer
PHPBeginner.com (Where PHP Begins)
maxim@phpbeginner.com
www.phpbeginner.com
-----Original Message-----
From: Hugh Danaher [mailto:hdanaher@earthlink.net]
Sent: Friday, August 10, 2001 5:43 PM
To: Maxim Maletsky
Cc: Php-General
Subject: Re: [PHP] Image header problems
Thanks for your help. Someone earlier caught the same error which was a
print call before the header. But in addition to removing line 4, I had to
remove lines 2 and 3 too. Even though they were empty, they also called the
browser and stopped the execution of the code.
Thanks again.
Hugh
----- Original Message -----
From: Maxim Maletsky <maxim@japaninc.com>
To: 'Hugh Danaher' <hdanaher@earthlink.net>; Php-General
<php-general@lists.php.net>
Sent: Thursday, August 09, 2001 6:04 PM
Subject: RE: [PHP] Image header problems
make it look this way:
1. <?php
2.
3.
4. # print "jpeg format<br>";
5. header("content-type: image/jpeg",replace);
6. $image=imagecreate(200,200);
7. $red=imagecolorallocate($image,255,0,0);
8. $blue=imagecolorallocate($image,0,0,255);
9. imagearc($image,99,99,180,180,0,360,$blue);
10. imagefill($image,99,99,$blue);
11. imagejpeg($image);
12. ?>
The problem are outputs before header();
Yoroshiku,
Maxim Maletsky
-----Original Message-----
From: Hugh Danaher [mailto:hdanaher@earthlink.net]
Sent: Friday, August 10, 2001 7:26 AM
To: Php-General
Subject: [PHP] Image header problems
I want to generate an image using the following code, and think it should
have worked. Unfortunately I get an error message saying the header info
has already been sent, and the browser (IE5) doesn't print a picture just
the
characterset representing the picture. I think I've got it right, but
obviously, I don't. Any help will be greatly appreciated.
1.
2.
3. <?php
4. print "jpeg format<br>";
5. header("content-type: image/jpeg",replace);
6. $image=imagecreate(200,200);
7. $red=imagecolorallocate($image,255,0,0);
8. $blue=imagecolorallocate($image,0,0,255);
9. imagearc($image,99,99,180,180,0,360,$blue);
10. imagefill($image,99,99,$blue);
11. imagejpeg($image);
?>
<html>
<body>
<img src="test.php" alt="a php generated image">
</body>
</html>
what I get is the following:
Warning: Cannot add header information - headers already sent by (output
started at /www/ironorchid/stocks/test.php:3) in
/www/ironorchid/stocks/test.php on line 5
ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), ...
A printout of the jpeg file (I think) and a broken link icon.