Jump to content


Photo

help me with gd


  • Please log in to reply
18 replies to this topic

#1 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 07 September 2006 - 08:36 PM

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


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


gd with phpinfo()
Posted Image

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 07 September 2006 - 08:54 PM

The code provided isnt the correct code AFAIK to create image with gd. Prehaps a have read of this tutorial. That tutorial shows you how to create basics shapes with PHP GD.

#3 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 07 September 2006 - 09:33 PM

i test the following code  and take it copy and paste to ensure code is rigth  but the result is
‰PNG 



the 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);

?>


#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 07 September 2006 - 09:43 PM

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">
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 07 September 2006 - 10:31 PM

no result ..wat i do ?

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 08 September 2006 - 01:13 AM

What does 'no result' mean?  The script hung?  You got a blank page? You got no image displayed? You got a 'missing' image displayed?

Legend has it that reading the manual never killed anyone.
My site

#7 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 08 September 2006 - 11:16 AM

when i run this 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);

?>


the result of this code is     

‰PNG 

  so no result clear

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 08 September 2006 - 11:23 AM

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
Legend has it that reading the manual never killed anyone.
My site

#9 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 September 2006 - 11:25 AM

Rather than creating a PNG, maybe your browser doesnt support PNG. try a jpeg image instead so use:
// 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);

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

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

#10 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 08 September 2006 - 08:06 PM

when i use this code
<?php echo '<pre>' . print_r(gd_info(), true) . '</pre>'; ?>


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] =>
)


#11 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 08 September 2006 - 11:58 PM

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


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


#12 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 09 September 2006 - 12:05 AM

Do you have error reporting switched off?

Put this at top of the script

error_reporting(E_ALL);


If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#13 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 12:08 AM

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.
Legend has it that reading the manual never killed anyone.
My site

#14 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 09 September 2006 - 02:02 AM

if any server program like AppServ support gd libary( work on loca)l ..plz tell me

#15 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 02:16 AM

doh!  Perhaps you could have explained it wasn't working on your local machine a little earlier in the thread.
Legend has it that reading the manual never killed anyone.
My site

#16 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 09 September 2006 - 06:33 PM

doh!  Perhaps you could have explained it wasn't working on your local machine a little earlier in the thread.


ok  :)...wat i do know ?

#17 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 08:11 PM

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. 
Legend has it that reading the manual never killed anyone.
My site

#18 ahmed17

ahmed17
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 09 September 2006 - 08:33 PM

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

#19 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 09:41 PM

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).
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users