473,783 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using GD Library Functions

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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
header("Content-type: image/jpeg");
imagejpeg($imag e);

?>

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_in fo());)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
Jul 17 '05 #1
15 19103
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_Alia s" <ze*********@ya hoo.com> wrote in message
news:e1******** *************** ***@posting.goo gle.com...
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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
header("Content-type: image/jpeg");
imagejpeg($imag e);

?>

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_in fo());)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

Jul 17 '05 #2
"Uncle_Alia s" <ze*********@ya hoo.com> wrote in message
news:e1******** *************** ***@posting.goo gle.com...
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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
header("Content-type: image/jpeg");
imagejpeg($imag e);

?>

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_in fo());)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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
//header("Content-type: image/jpeg");
imagejpeg($imag e);
?>

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

Jul 17 '05 #3

"SwissChees e" <Sw*********@cf l.rr.com> wrote in message
news:F8******** **************@ twister.tampaba y.rr.com...
"Uncle_Alia s" <ze*********@ya hoo.com> wrote in message
news:e1******** *************** ***@posting.goo gle.com...
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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
header("Content-type: image/jpeg");
imagejpeg($imag e);

?>

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_in fo());)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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
//header("Content-type: image/jpeg");
imagejpeg($imag e);
?>

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_inf o as $key=>$element)
{
print("<br>$key = $element");
}
?>

laters
Randell D.
Jul 17 '05 #4
On 2004-01-03, Randell D. <re************ **********@and. share.com> wrote:

"SwissChees e" <Sw*********@cf l.rr.com> wrote in message
news:F8******** **************@ twister.tampaba y.rr.com...
"Uncle_Alia s" <ze*********@ya hoo.com> wrote in message
news:e1******** *************** ***@posting.goo gle.com...
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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
header("Content-type: image/jpeg");
imagejpeg($imag e);

?>

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_in fo());)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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
//header("Content-type: image/jpeg");
imagejpeg($imag e);
?>

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 InternetExplore r/6.1/Win32 i get a red square.
--
verum ipsum factum
Jul 17 '05 #5
"Randell D." <re************ **********@and. share.com> wrote in message news:<RPpJb.917 448$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_inf o 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>
Jul 17 '05 #6
http://gzen.myhq.info -- free online php tools
"Uncle_Alia s" <ze*********@ya hoo.com> wrote in message
news:e1******** *************** **@posting.goog le.com...
"Randell D." <re************ **********@and. share.com> wrote in message news:<RPpJb.917 448$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_inf o 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

Jul 17 '05 #7
tom
Randell D. wrote:
"SwissChees e" <Sw*********@cf l.rr.com> wrote in message
news:F8******** **************@ twister.tampaba y.rr.com...
"Uncle_Alia s" <ze*********@ya hoo.com> wrote in message
news:e1******** *************** ***@posting.goo gle.com...
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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
header("Content-type: image/jpeg");
imagejpeg($imag e);

?>

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_in fo());)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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
//header("Content-type: image/jpeg");
imagejpeg($imag e);
?>

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
Jul 17 '05 #8

"tom" <te**@nospam.co m> wrote in message
news:bt******** ***********@new s.demon.co.uk.. .
Randell D. wrote:
"SwissChees e" <Sw*********@cf l.rr.com> wrote in message
news:F8******** **************@ twister.tampaba y.rr.com...
"Uncle_Alia s" <ze*********@ya hoo.com> wrote in message
news:e1******** *************** ***@posting.goo gle.com...
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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
header("Content-type: image/jpeg");
imagejpeg($imag e);

?>

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_in fo());)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 = imagecoloralloc ate($image, 255, 0, 0);
imagefill($imag e, 0, 0, $colorRed);

//send image
//header("Content-type: image/jpeg");
imagejpeg($imag e);
?>

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.
Jul 17 '05 #9

"Randell D." <re************ **********@and. share.com> wrote in message
news:<RPpJb.917 448$pl3.238882@ pd7tw3no>...
If you want to see what type of GD support you have, try
<?
$gdinfo=gd_info ();
foreach($gd_inf o 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.
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6704
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
0
5221
by: Reed | last post by:
Can someone stear me in the right direction to convert a binary tree from a Linked List to a Dynamic Array... Dynamic arrays aren't something im strong with. //********bintree.h******** #ifndef BINTREE_H #define BINTREE_H #include <cstdlib> // Provides NULL and size_t
4
3780
by: Chris Goller | last post by:
Imagine a cross platform library. A particular object wraps up operating system specific functionality and presents it in a uniform manner. Generally, people use ifdefs to change the functionality of a particular piece of code to match that of the native operating system (#ifdef _WINDOWS, etc) I'm wondering if it is possible to use templates to accomplish this same functionality.
10
1619
by: David Soukal | last post by:
Hello, I have an interesting problem that I'm tackling with. I'm sure there must be some obvious solution... I have this big project. It's composed of several *.lib modules. Now, one of the modules uses IJG JPEG library. But, another module needs to use *modified* verzion of the library: the application displays images - for that it uses "normal" jpeg-6b library. However, some functionality is required that modifies the jpeg files as...
19
78838
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not find one.
3
1592
by: Manny Silva | last post by:
Hi, I would like to create a static library that uses and in effect adds to another static library. I could simply add functionality to the existing library, but functionally it doesn't really belong there... that is, the one library is very inspecific. The Library I need to create will be project specific, and I prefer not to have to mix the two... in any case, I tried to create a library that referenced the first library. I added...
1
3568
by: mmacrobert | last post by:
Hi Everyone, I've created a 'C' dll that is accessed via ctypes library containing a bunch of functions. I've successfully been able to use the functions. However, I would like to throw python exceptions from some of them. I throw them using: ::PyErr_SetString(::PyExc_RuntimeError, theErrorString); I crash the console when this function is invoked in the 'C' domain. I
10
1401
by: Anil Gupte | last post by:
In one VB.Net 2003 solution, I have three projects (one in the installer project and not relevant here). However, the other two are the ones where I want to share some commone fucntions. One is a Windows Forms based app and the other is a Windows Service. Is this possible? TIA, -- Anil Gupte www.keeninc.net www.icinema.com
83
4236
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about it too? Once I saw a website comparing Prototype to Java and jQuery to Ruby... but now that I read more and more about Prototype, it is said that Prototype actually came from Ruby on Rails development and the creator of Prototype created it...
16
3284
by: Xiaoxiao | last post by:
Hi, I got a C library, is there a way to view the public function names in this library so that I can use in my C program? Thanks.
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.