Jump to content

Archived

This topic is now archived and is closed to further replies.

ahmed17

help me with gd

Recommended Posts

very weird problem with gd libary all time and i try more but no way
i used phpinfo() method to ensure if gd libary setup or not and  i am not found it installing and i ask
somebody wat i do then i found php.ini (configuration) and i remove  ; form gd then when i used  phpinfo
it appear
but when i run any code no result appears


[code]<?php
header("Content-type: image/gif");
$image= imagecreate(100,100)
or die("Cannot Initialize new GD image stream");
imagegif($im);
?>[/code]


gd with phpinfo()
[img]http://ahmed17.xlphp.net/gd.gif[/img]

Share this post


Link to post
Share on other sites
The code provided isnt the correct code AFAIK to create image with gd. Prehaps a have read of [url=http://www.design-ireland.net/graphics/imagery-15.php]this[/url] tutorial. That tutorial shows you how to create basics shapes with PHP GD.

Share this post


Link to post
Share on other sites
i test the following code  and take it copy and paste to ensure code is rigth  but the result is
[code]‰PNG  [/code]


the code
****************
[code]
<?php

// example1.php

// set the HTTP header type to PNG
header("Content-type: image/png");

// set the width and height of the new image in pixels
$width = 350;
$height = 360;

// create a pointer to a new true colour image
$im = ImageCreateTrueColor($width, $height);

// sets background to red
$red = ImageColorAllocate($im, 255, 0, 0);
ImageFillToBorder($im, 0, 0, $red, $red);

// send the new PNG image to the browser
ImagePNG($im);

// destroy the reference pointer to the image in memory to free up resources
ImageDestroy($im);

?>[/code]

Share this post


Link to post
Share on other sites
Looks fine - when I ran it I got a red square.

Try putting this code on another page in the same folder

<img src="example.php">

Share this post


Link to post
Share on other sites
What does 'no result' mean?  The script hung?  You got a blank page? You got no image displayed? You got a 'missing' image displayed?

Share this post


Link to post
Share on other sites
when i run this code
[code]<?php

// example1.php

// set the HTTP header type to PNG
header("Content-type: image/png");

// set the width and height of the new image in pixels
$width = 350;
$height = 360;

// create a pointer to a new true colour image
$im = ImageCreateTrueColor($width, $height);

// sets background to red
$red = ImageColorAllocate($im, 255, 0, 0);
ImageFillToBorder($im, 0, 0, $red, $red);

// send the new PNG image to the browser
ImagePNG($im);

// destroy the reference pointer to the image in memory to free up resources
ImageDestroy($im);

?>[/code]


the result of this code is      [quote] ‰PNG  [/quote]  so no result clear

Share this post


Link to post
Share on other sites
When I run exactly the same code using Firefox, I see a large red square.

I'd say there's something wrong with your GD library and/or set-up. Time to ask your web host for assistance

Share this post


Link to post
Share on other sites
Rather than creating a PNG, maybe your browser doesnt support PNG. try a jpeg image instead so use:
[code=php:0]
// example1.php

// set the HTTP header type to JPEG
header("Content-type: image/jpeg");

// set the width and height of the new image in pixels
$width = 350;
$height = 360;

// create a pointer to a new true colour image
$im = ImageCreateTrueColor($width, $height);

// sets background to red
$red = ImageColorAllocate($im, 255, 0, 0);
ImageFillToBorder($im, 0, 0, $red, $red);

// send the new GIF image to the browser
Imagejpeg($im);

// destroy the reference pointer to the image in memory to free up resources
ImageDestroy($im);[/code]

Goto example.php you should get a red box. Also what does this return:
[code]<?php echo '<pre>' . print_r(gd_info(), true) . '</pre>'; ?>[/code]

Also what OS is your server running on, *nix (linux, unix, mac) or Windows?

Share this post


Link to post
Share on other sites
when i use this code
[code]<?php echo '<pre>' . print_r(gd_info(), true) . '</pre>'; ?>[/code]


the result is

Array
(
    [GD Version] => bundled (2.0 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] =>
    [GIF Read Support] =>
    [GIF Create Support] =>
    [JPG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XBM Support] =>
)

Share this post


Link to post
Share on other sites
[quote author=AndyB link=topic=107272.msg430480#msg430480 date=1157714602]
When I run exactly the same code using Firefox, I see a large red square.

I'd say there's something wrong with your GD library and/or set-up. Time to ask your web host for assistance
[/quote]

I run exactly the same code using Firefox, but give the same result
[code]‰PNG  [/code]

Share this post


Link to post
Share on other sites
Do you have error reporting switched off?

Put this at top of the script
[code]

error_reporting(E_ALL);

[/code]

Share this post


Link to post
Share on other sites
Well, just to close out the loop of my results - example1.php generates the image that I can see running Firefox 1.0.7 (unchanged since I downloaded it) on a PC with Win2K Pro.

Share this post


Link to post
Share on other sites
doh!  Perhaps you could have explained it wasn't working on your local machine a little earlier in the thread.

Share this post


Link to post
Share on other sites
[quote author=AndyB link=topic=107272.msg431043#msg431043 date=1157768168]
doh!  Perhaps you could have explained it wasn't working on your local machine a little earlier in the thread.
[/quote]

ok  :)...wat i do know ?

Share this post


Link to post
Share on other sites
I'll tell you what I do.  GD doesn't run on my local machine either, so I do all of my final GD testing on a live web server off in a separate test folder. 

Share this post


Link to post
Share on other sites
thanks AndyB more :D
Gd work on a live web server  now .. but testing script will take long time if i design it and then upload to test ....for this perphas i ask how i  can test gd on local machine

Share this post


Link to post
Share on other sites
OK, start a new topic. I suggest titling it "GD on localhost" so everyone will know what you're trying to do.

State exactly what you have for the server O/S, what version of php you're running, and that you have GD2 as part of the package and quote the GD info that you quoted earlier in this thread.  That should get you the assistance you need (let's hope).

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.