Page 1 of 1

image problems

Posted: Wed Jun 28, 2006 9:42 pm
by psychotomus

Code: Select all

<?php

$srcimg = imagecreatefromjpeg ("./otwanted.jpg") or die ("Problem In opening Source Image");  // For JPEG 
$textcolor = imagecolorallocate($srcimg, 0, 0, 255); 
imagestring($srcimg, 5, 0, 0, $_GET['caption'], $textcolor);
header("Content-type: image/jpeg");
imagejpeg($srcimg); 
exit();
?>
doesn't print the image but the source of the image.
http://po2shoutbox.com/test1.php look.

Posted: Wed Jun 28, 2006 10:07 pm
by basdog22
If you turn error reporting on ( error_reporting(E_ALL); ) you will see some errors like:

Headers already sent by....

This means that when you use the header(); function there must be no output before this function. Try doing the same script without the form :wink:

Posted: Thu Jun 29, 2006 2:09 pm
by psychotomus
i get the same error if i put the form below the php code.

Posted: Fri Jun 30, 2006 1:38 pm
by psychotomus
anybody?

Posted: Fri Jun 30, 2006 3:14 pm
by IceMetalPunk
I'm not sure, but try changing

Code: Select all

header("Content-type: image/jpeg");
To this:

Code: Select all

header("Content-type: image/jpg");
-IMP ;) :)

Posted: Fri Jun 30, 2006 6:08 pm
by bokehman
You can't output HTML markup and an image on the same request. You can output one or the other but not both.

Posted: Fri Jun 30, 2006 7:07 pm
by IceMetalPunk
Who's outputting HTML?

-IMP ;) :)

Posted: Fri Jun 30, 2006 7:10 pm
by John Cartwright
IceMetalPunk wrote:Who's outputting HTML?

-IMP ;) :)
try visiting the OP's link

Posted: Fri Jun 30, 2006 7:23 pm
by psychotomus
do I need the header?

Posted: Fri Jun 30, 2006 7:27 pm
by psychotomus
bokehman wrote:You can't output HTML markup and an image on the same request. You can output one or the other but not both.
then how do i output HTML and an image???

Posted: Fri Jun 30, 2006 8:03 pm
by dull1554
you will have your php script to generate your image
example: image.php

then you will have a page that outputs html

exa,ple: index.php

call your image like this

<img src="img/image.php" />

Posted: Sat Jul 01, 2006 4:30 am
by bokehman
psychotomus wrote:
bokehman wrote:You can't output HTML markup and an image on the same request. You can output one or the other but not both.
then how do i output HTML and an image???
On separate requests. Each item on a website is retrieved through an individual request to the server... So if a document is made up of an HTML string and two images, altogether three requests will be sent to the server from the client's browser. An yes... you do need a mime header. It tells the web browser what the content is so it know how to display it.

Posted: Sat Jul 01, 2006 7:13 pm
by Ollie Saunders
the content-type header isn't being sent (see)

As there are no configuration directives for header() in PHP that might prevent it from working I'd look to problems with your webserver. Ah I've just noticed that your server is sending a server header of "Servage.net Cluster (Enhanced Apache)". What exactly is that?

You might want to check there isn't some kind of limitation the webserver is imposing on PHP or that header() is even compatable with your webserver.

Posted: Sun Jul 02, 2006 2:46 pm
by psychotomus
How Can I change the Text Properties when placing text on the image such as the Height?