I would like use some of the GD image functions, so I ran a couple of
short scripts to see if it worked, such as:
<?php
/* Create a red square */
$image = imagecreate(200, 200);
$colorRed = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $colorRed);
//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting
with:
ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default
quality ÿÛC ... (etc.)
I then ran a script to see what version was installed
(var_dump(gd_info());)and it generated: ["GD Version"]=> string(24)
"bundled (2.0 compatible)"
So why doesn't it generate a jpeg? Am I doing something incorrectly or
is it the library itself? (This is using a hosting account at
godaddy.com. It is not PHP or a GD library that I installed).
Thanks,
Eric 15 18897
Can you post a link to a test? I can use my server check on my site to take
a look at whats going on.
--
Mike Bradley http://gzen.myhq.info -- free online php tools
"Uncle_Alias" <ze*********@yahoo.com> wrote in message
news:e1**************************@posting.google.c om... I would like use some of the GD image functions, so I ran a couple of short scripts to see if it worked, such as:
<?php
/* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image header("Content-type: image/jpeg"); imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting with: ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC ... (etc.)
I then ran a script to see what version was installed (var_dump(gd_info());)and it generated: ["GD Version"]=> string(24) "bundled (2.0 compatible)"
So why doesn't it generate a jpeg? Am I doing something incorrectly or is it the library itself? (This is using a hosting account at godaddy.com. It is not PHP or a GD library that I installed).
Thanks, Eric
"Uncle_Alias" <ze*********@yahoo.com> wrote in message
news:e1**************************@posting.google.c om... I would like use some of the GD image functions, so I ran a couple of short scripts to see if it worked, such as:
<?php
/* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image header("Content-type: image/jpeg"); imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting with: ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC ... (etc.)
I then ran a script to see what version was installed (var_dump(gd_info());)and it generated: ["GD Version"]=> string(24) "bundled (2.0 compatible)"
So why doesn't it generate a jpeg? Am I doing something incorrectly or is it the library itself? (This is using a hosting account at godaddy.com. It is not PHP or a GD library that I installed).
Thanks, Eric
Copied your script to my server and it worked just fine... you really
don't even need the 'header...' line either...
<?PHP
$image = imagecreate(200, 200);
$colorRed = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $colorRed);
//send image
//header("Content-type: image/jpeg");
imagejpeg($image);
?>
here is a link: http://www.suddenimpactfans.com/getphoto3.php
It could be a problem on your host side - although the only time I get text
output from the GD stuff is if there is an error in one of the function
calls...
"SwissCheese" <Sw*********@cfl.rr.com> wrote in message
news:F8**********************@twister.tampabay.rr. com...
"Uncle_Alias" <ze*********@yahoo.com> wrote in message
news:e1**************************@posting.google.c om... I would like use some of the GD image functions, so I ran a couple of short scripts to see if it worked, such as:
<?php
/* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image header("Content-type: image/jpeg"); imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting with: ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC ... (etc.)
I then ran a script to see what version was installed (var_dump(gd_info());)and it generated: ["GD Version"]=> string(24) "bundled (2.0 compatible)"
So why doesn't it generate a jpeg? Am I doing something incorrectly or is it the library itself? (This is using a hosting account at godaddy.com. It is not PHP or a GD library that I installed).
Thanks, Eric
Copied your script to my server and it worked just fine... you really
don't even need the 'header...' line either...
<?PHP
$image = imagecreate(200, 200);
$colorRed = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $colorRed);
//send image
//header("Content-type: image/jpeg");
imagejpeg($image);
?>
here is a link: http://www.suddenimpactfans.com/getphoto3.php
It could be a problem on your host side - although the only time I get text
output from the GD stuff is if there is an error in one of the function
calls...
--
====================================
Eric,
I'm just wondering if its a header problem.... Make sure you have no spaces
before your <?PHP tag...
If you want to see what type of GD support you have, try
<?
$gdinfo=gd_info();
foreach($gd_info as $key=>$element)
{
print("<br>$key = $element");
}
?>
laters
Randell D.
On 2004-01-03, Randell D. <re**********************@and.share.com> wrote: "SwissCheese" <Sw*********@cfl.rr.com> wrote in message news:F8**********************@twister.tampabay.rr. com... "Uncle_Alias" <ze*********@yahoo.com> wrote in message news:e1**************************@posting.google.c om... I would like use some of the GD image functions, so I ran a couple of short scripts to see if it worked, such as:
<?php
/* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image header("Content-type: image/jpeg"); imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting with: ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC ... (etc.)
I then ran a script to see what version was installed (var_dump(gd_info());)and it generated: ["GD Version"]=> string(24) "bundled (2.0 compatible)"
So why doesn't it generate a jpeg? Am I doing something incorrectly or is it the library itself? (This is using a hosting account at godaddy.com. It is not PHP or a GD library that I installed).
Thanks, Eric
Copied your script to my server and it worked just fine... you really don't even need the 'header...' line either...
<?PHP $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image //header("Content-type: image/jpeg"); imagejpeg($image); ?>
here is a link: http://www.suddenimpactfans.com/getphoto3.php
It could be a problem on your host side - although the only time I get text output from the GD stuff is if there is an error in one of the function calls...
When using Mozilla/1.6b/Win32 i get some scrambled text.
When using InternetExplorer/6.1/Win32 i get a red square.
--
verum ipsum factum
"Randell D." <re**********************@and.share.com> wrote in message news:<RPpJb.917448$pl3.238882@pd7tw3no>...
.... Eric,
I'm just wondering if its a header problem.... Make sure you have no spaces before your <?PHP tag...
If you want to see what type of GD support you have, try <? $gdinfo=gd_info(); foreach($gd_info as $key=>$element) { print("<br>$key = $element"); } ?>
laters Randell D.
Aha! That was it: I moved the PHP code to before the <html> tag - I
had it in the body. Now it works.
So tell this newbie: why does this PHP code need to not be in the
<body> section? Other PHP code I've run has worked fine in the body.
Thanks,
Eric
BTW I couldn't get your GD support check code to work. <scratch head> http://gzen.myhq.info -- free online php tools
"Uncle_Alias" <ze*********@yahoo.com> wrote in message
news:e1*************************@posting.google.co m... "Randell D." <re**********************@and.share.com> wrote in message
news:<RPpJb.917448$pl3.238882@pd7tw3no>... ...
Eric,
I'm just wondering if its a header problem.... Make sure you have no
spaces before your <?PHP tag...
If you want to see what type of GD support you have, try <? $gdinfo=gd_info(); foreach($gd_info as $key=>$element) { print("<br>$key = $element"); } ?>
laters Randell D.
Aha! That was it: I moved the PHP code to before the <html> tag - I had it in the body. Now it works. So tell this newbie: why does this PHP code need to not be in the <body> section? Other PHP code I've run has worked fine in the body.
Thanks, Eric
BTW I couldn't get your GD support check code to work. <scratch head>
there should bo NO body section, we (i assume everyone else here) thought
that was your complete script.
you are to send out a <BODY> tag if you are sending out an .html page,
becouse html pages continain, a body.
when you are sending out image data, send out only image data.
Think of it not as html with php in it, but rather a scripting lanugage
thats send out plain data outside the <?php ?> tags
so, with this line of though, php can send out any type of data. in fact
some people (myself included) dont have any text outside the <?php ?> tags,
and use it soley as a scripting laguage.
now, if a script needed to send, lets say the <HTML> tag, 2 ways
<HTML>
<?php
some script....
?>
</HTML>
or
<?php
print "<HTML>\n";
some script...
print "</HTML>\n";
?>
so you see, anything outside the <?php ?> tags is send directly to the
browser.
--
Mike Bradley
Randell D. wrote: "SwissCheese" <Sw*********@cfl.rr.com> wrote in message news:F8**********************@twister.tampabay.rr. com... "Uncle_Alias" <ze*********@yahoo.com> wrote in message news:e1**************************@posting.google.c om... I would like use some of the GD image functions, so I ran a couple of short scripts to see if it worked, such as:
<?php
/* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image header("Content-type: image/jpeg"); imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting with: ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC ... (etc.)
I then ran a script to see what version was installed (var_dump(gd_info());)and it generated: ["GD Version"]=> string(24) "bundled (2.0 compatible)"
So why doesn't it generate a jpeg? Am I doing something incorrectly or is it the library itself? (This is using a hosting account at godaddy.com. It is not PHP or a GD library that I installed). Thanks, Eric
Copied your script to my server and it worked just fine... you really don't even need the 'header...' line either...
<?PHP $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image //header("Content-type: image/jpeg"); imagejpeg($image); ?>
here is a link: http://www.suddenimpactfans.com/getphoto3.php
It could be a problem on your host side - although the only time I get text output from the GD stuff is if there is an error in one of the function calls...
help - I see loadsa junk on konqueror, and a few lines of junk with netscape
thanks, tom
"tom" <te**@nospam.com> wrote in message
news:bt*******************@news.demon.co.uk... Randell D. wrote: "SwissCheese" <Sw*********@cfl.rr.com> wrote in message news:F8**********************@twister.tampabay.rr. com... "Uncle_Alias" <ze*********@yahoo.com> wrote in message news:e1**************************@posting.google.c om... I would like use some of the GD image functions, so I ran a couple of short scripts to see if it worked, such as:
<?php
/* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image header("Content-type: image/jpeg"); imagejpeg($image);
?>
but all they generates are garbage characters and no image, starting with: ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC ... (etc.)
I then ran a script to see what version was installed (var_dump(gd_info());)and it generated: ["GD Version"]=> string(24) "bundled (2.0 compatible)"
So why doesn't it generate a jpeg? Am I doing something incorrectly or is it the library itself? (This is using a hosting account at godaddy.com. It is not PHP or a GD library that I installed). Thanks, Eric
Copied your script to my server and it worked just fine... you really don't even need the 'header...' line either...
<?PHP $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//send image //header("Content-type: image/jpeg"); imagejpeg($image); ?>
here is a link: http://www.suddenimpactfans.com/getphoto3.php
It could be a problem on your host side - although the only time I get text output from the GD stuff is if there is an error in one of the function calls...
help - I see loadsa junk on konqueror, and a few lines of junk with
netscape thanks, tom
Try it now - I enabled the header line as Opera 7+ gave junk too, but now
doesn't with the header line.
"Randell D." <re**********************@and.share.com> wrote in message
news:<RPpJb.917448$pl3.238882@pd7tw3no>... If you want to see what type of GD support you have, try <? $gdinfo=gd_info(); foreach($gd_info as $key=>$element) { print("<br>$key = $element"); } ?>
laters Randell D.
Aha! That was it: I moved the PHP code to before the <html> tag - I
had it in the body. Now it works.
So tell this newbie: why does this PHP code need to not be in the
<body> section? Other PHP code I've run has worked fine in the body.
Thanks,
Eric
BTW I couldn't get your GD support check code to work. <scratch head>
--
====================================
Hi again,
I don't know why you couldn't get the above code to work... take a look at http://ca3.php.net/manual/en/function.gd-info.php
If will tell you what functionality the gdlib can give you (this can vary
pending what libraries you have installed). The gd_info() function should
work on any PHP 4 forward...
If that doesn't work, try phpinfo(); and examine any mention of GD in its
output...
Lastly... when outputing an image, it is handled differently by the web
client than when sending text... It has to do with headers... this might be
the reason as to why you are getting mixed results from browser to
browser... Some browsers might attempt to be intelligent and guess what data
is being sent to them, while othes will just display the binary data that
makes up the image (aka junk to you and I). I would suggest that you write
your test image to a file first, then have your HTML request the image with
the html <img> tag.... Once you've solved that, then I'd go one step further
to work on dynamic images if that's your thing...
Replies please... via the newsgroup, so everyone can learn... and happy new
year,
Thanks,
Randell D.
"CountScubula" <me@scantek.hotmail.com> wrote in message news:<KD*****************@newssvr27.news.prodigy.c om>... there should bo NO body section, we (i assume everyone else here) thought that was your complete script.
you are to send out a <BODY> tag if you are sending out an .html page, becouse html pages continain, a body.
when you are sending out image data, send out only image data.
Think of it not as html with php in it, but rather a scripting lanugage thats send out plain data outside the <?php ?> tags
so, with this line of though, php can send out any type of data. in fact some people (myself included) dont have any text outside the <?php ?> tags, and use it soley as a scripting laguage.
now, if a script needed to send, lets say the <HTML> tag, 2 ways
<HTML> <?php some script.... ?> </HTML>
or
<?php print "<HTML>\n"; some script... print "</HTML>\n"; ?>
so you see, anything outside the <?php ?> tags is send directly to the browser.
Interesting. OK, and I find out from the php.net site that for the
imagejpeg() function that "The filename argument is optional, and if
left off, the raw image stream will be output directly."
( http://www.php.net/manual/en/function.imagejpeg.php)
So that's why one gets either text garbage or an image and nothing
else - it's just an image that's output DIRECTLY to the browser.
So... if I wanted to create the image and have my cake and eat it too,
I could (supposedly) save it and then display it with an HTML image
tag, like:
<html>
<head>
<title>Listing 12-2a</title>
</head>
<body>
<?php
/* Create a red square */
$image = imagecreate(200, 200);
$colorRed = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $colorRed);
//save image then use later
imagejpeg($image, "pic.jpg");
imagedestroy($image);
?>
<img src="pic.jpg" border=0>
<br>Here is some text.
</body>
</html>
Well, I tried this but it can't find (doesn't display) the image.
Where'd it go? I looked in my hosting account directories but couldn't
find it anywhere. I assumed it would appear in the directory where the
PHP script was run.
On 2004-01-04, Uncle_Alias <ze*********@yahoo.com> wrote: <?php /* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//save image then use later imagejpeg($image, "pic.jpg"); imagedestroy($image); ?>
<img src="pic.jpg" border=0> <br>Here is some text. </body> </html>
Well, I tried this but it can't find (doesn't display) the image. Where'd it go? I looked in my hosting account directories but couldn't find it anywhere. I assumed it would appear in the directory where the PHP script was run.
This way, you need to make sure that the user which is running
apache/php (usually nobody or www-data) has the rights to write such a
file at that place.
--
verum ipsum factum
Tim Van Wassenhove wrote: On 2004-01-04, Uncle_Alias <ze*********@yahoo.com> wrote:
<?php /* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//save image then use later imagejpeg($image, "pic.jpg"); imagedestroy($image);
<img src="pic.jpg" border=0> <br>Here is some text. </body> </html>
Well, I tried this but it can't find (doesn't display) the image. Where'd it go? I looked in my hosting account directories but couldn't find it anywhere. I assumed it would appear in the directory where the PHP script was run.
This way, you need to make sure that the user which is running apache/php (usually nobody or www-data) has the rights to write such a file at that place.
What tim said.
Also, note that if you have a page that's something like:
<?php
// this file is somepage.php
header(stuff for jpeg); // too lazy to remember syntax
....
imagejpeg($img);
?>
you can do
<img src="somepage.php">
SwissCheese wrote: "tom" <te**@nospam.com> wrote in message news:bt*******************@news.demon.co.uk... Randell D. wrote: > "SwissCheese" <Sw*********@cfl.rr.com> wrote in message > news:F8**********************@twister.tampabay.rr. com... > "Uncle_Alias" <ze*********@yahoo.com> wrote in message > news:e1**************************@posting.google.c om... >> I would like use some of the GD image functions, so I ran a couple of >> short scripts to see if it worked, such as: >> >> <?php >> >> /* Create a red square */ >> $image = imagecreate(200, 200); >> $colorRed = imagecolorallocate($image, 255, 0, 0); >> imagefill($image, 0, 0, $colorRed); >> >> //send image >> header("Content-type: image/jpeg"); >> imagejpeg($image); >> >> ?> >> >> but all they generates are garbage characters and no image, starting >> with: >> ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default >> quality ÿÛC ... (etc.) >> >> I then ran a script to see what version was installed >> (var_dump(gd_info());)and it generated: ["GD Version"]=> string(24) >> "bundled (2.0 compatible)" >> >> >> So why doesn't it generate a jpeg? Am I doing something incorrectly or >> is it the library itself? (This is using a hosting account at >> godaddy.com. It is not PHP or a GD library that I installed). >> Thanks, >> Eric >> > > Copied your script to my server and it worked just fine... you > really > don't even need the 'header...' line either... > > <?PHP > $image = imagecreate(200, 200); > $colorRed = imagecolorallocate($image, 255, 0, 0); > imagefill($image, 0, 0, $colorRed); > > //send image > //header("Content-type: image/jpeg"); > imagejpeg($image); > ?> > > here is a link: http://www.suddenimpactfans.com/getphoto3.php > > It could be a problem on your host side - although the only time I get > text output from the GD stuff is if there is an error in one of the > function calls...
help - I see loadsa junk on konqueror, and a few lines of junk with netscape thanks, tom
Try it now - I enabled the header line as Opera 7+ gave junk too, but now doesn't with the header line.
worked - thanks (I still get this on my server though - and need to keep at
it), tom
"Agelmar" <if**********@comcast.net> wrote in message news:<bt************@ID-30799.news.uni-berlin.de>... Tim Van Wassenhove wrote: On 2004-01-04, Uncle_Alias <ze*********@yahoo.com> wrote:
<?php /* Create a red square */ $image = imagecreate(200, 200); $colorRed = imagecolorallocate($image, 255, 0, 0); imagefill($image, 0, 0, $colorRed);
//save image then use later imagejpeg($image, "pic.jpg"); imagedestroy($image);
<img src="pic.jpg" border=0> <br>Here is some text. </body> </html>
Well, I tried this but it can't find (doesn't display) the image. Where'd it go? I looked in my hosting account directories but couldn't find it anywhere. I assumed it would appear in the directory where the PHP script was run.
This way, you need to make sure that the user which is running apache/php (usually nobody or www-data) has the rights to write such a file at that place.
What tim said.
Also, note that if you have a page that's something like: <?php // this file is somepage.php header(stuff for jpeg); // too lazy to remember syntax ... imagejpeg($img); ?>
you can do <img src="somepage.php">
Yeah, that works. Cool. Raises all kinds of possibilities...
"Randell D." <re**********************@and.share.com> wrote in message news:<%NIJb.931853$pl3.509732@pd7tw3no>... -- ==================================== Hi again, I don't know why you couldn't get the above code to work... take a look at http://ca3.php.net/manual/en/function.gd-info.php
If will tell you what functionality the gdlib can give you (this can vary pending what libraries you have installed). The gd_info() function should work on any PHP 4 forward...
If that doesn't work, try phpinfo(); and examine any mention of GD in its output...
Lastly... when outputing an image, it is handled differently by the web client than when sending text... It has to do with headers... this might be the reason as to why you are getting mixed results from browser to browser... Some browsers might attempt to be intelligent and guess what data is being sent to them, while othes will just display the binary data that makes up the image (aka junk to you and I). I would suggest that you write your test image to a file first, then have your HTML request the image with the html <img> tag.... Once you've solved that, then I'd go one step further to work on dynamic images if that's your thing...
Replies please... via the newsgroup, so everyone can learn... and happy new year, Thanks, Randell D.
phpinfo(); is disabled in the configuration of PHP at my hosting
account. I guess they don't want people hacking it?:
"The following functions have been disabled on our Unix servers:
fpassthru
file
mail
exec
system
passthru
popen
crack_check
crack_closedict
crack_getlastmessage
crack_opendict
fsockopen
psockopen
opendir
readdir
closedir
phpinfo
all Posix functions"
Maybe this explains why gd_info() doesn't work. (It is PHP 4.3.1 BTW).
Funny thing is, I used the mail function in a small script, and it
worked. Go figure.
Eric This discussion thread is closed Replies have been disabled for this discussion. Similar topics
reply
views
Thread by Nashat Wanly |
last post: by
|
reply
views
Thread by Reed |
last post: by
|
4 posts
views
Thread by Chris Goller |
last post: by
|
10 posts
views
Thread by David Soukal |
last post: by
|
19 posts
views
Thread by Paul |
last post: by
|
3 posts
views
Thread by Manny Silva |
last post: by
|
1 post
views
Thread by mmacrobert |
last post: by
|
10 posts
views
Thread by Anil Gupte |
last post: by
|
83 posts
views
Thread by liketofindoutwhy |
last post: by
|
16 posts
views
Thread by Xiaoxiao |
last post: by
| | | | | | | | | | |