|
-
Aug 31st, 2006, 01:08 AM
#1
Thread Starter
Hyperactive Member
GD Library for Beginners
I download the GD library but I connot use it. Please show me how to use this.
-
Aug 31st, 2006, 02:40 AM
#2
<?="Moderator"?>
Re: GD Library for Beginners
A good place to start is
http://uk2.php.net/manual/en/ref.image.php
Also check out the comments on the manual pages, you'll find some good example there.
-
Sep 1st, 2006, 12:51 AM
#3
Re: GD Library for Beginners
 Originally Posted by systech44
I download the GD library but I connot use it. Please show me how to use this.
What operating system are you using? In windows you don't need to download it, ou justneed to edit the php.ini file and enablle the GD extension.
-
Sep 19th, 2008, 02:57 AM
#4
Thread Starter
Hyperactive Member
Re: GD Library for Beginners
Hi VisualAd,
Thanks for the reply.
I am using Windows. In php.ini file I delete ';' of this ';extension=php_gd2.dll' line. I am writing the following code.
PHP Code:
<?php
// AnalogClock :
// This small PHP3 script has been written by Christophe Lauer
// (mailto:[email protected]) to serve as an example for libgd.
//
// Feel free to use it as you like, you're even allowed to say
// it's your's if you like... Mail me if you like it, or if you
// can write it shorter. Comments are welcome ;-) This is e********
//
function draw_radius($img, $x, $y, $r, $ang, $col)
{
$x1 = $x + $r * cos($ang);
$y1 = $y + $r * sin($ang);
ImageLine($img, $x, $y, $x1, $y1, $col);
}
dl('php3_gd.dll');
// Win32 users should replace prev line with dl('php3_gd.dll');
// specify coords for the origins of the hands
// depends of the picture used as a background - draw your own !
$centrx = 29;
$centry = 29;
// depends on the background picture too.
$rmin = 22 ; // radius for minutes hand
$rhour = 12; // radius for hours hand
//
// ^ -Pi/2 rad => 0 min
// |
// |
// |
// |
// --------> O rad => 15 min
//
$minrad = -1 * (pi()/2) ; // origin is -PI/2
$hourrad = -1 * (pi()/2) ; // same as above.
// Calculate the angles for drawing the hands
$hour = (date("h")/12)*2*pi() - (pi()/2);
$min = (date("i")/60)*2*pi() - (pi()/2);
// Output the HTTP header Content-type
Header('Content-type: image/gif');
// specify path to background image file
$mypath = '/home/clauer/php3sampl/images/';
// Load watch background picture from file
$im = ImageCreateFromGIF($mypath.'watchframe.gif');
// Use pseudo "phosphore" light green for both hands
$mycolor = ImageColorAllocate($im, 153, 255, 204);
// Draw the hours and minutes hands
draw_radius($im, $centrx, $centry, $rmin, $min, $mycolor);
draw_radius($im, $centrx, $centry, $rhour, $hour, $mycolor);
// Send GIF output to client
ImageGif($im);
ImageDestroy($im);
?>
Result is as below.
Warning: dl() [function.dl]: Dynamically loaded extensions aren't allowed when running in Safe Mode in /home/go/public_html/mysticscripts/test_gd.php on line 27
Warning: Cannot modify header information - headers already sent by (output started at /home/go/public_html/mysticscripts/test_gd.php:7) in /home/go/public_html/mysticscripts/test_gd.php on line 56
Fatal error: Call to undefined function imagecreatefromgif() in /home/go/public_html/mysticscripts/test_gd.php on line 62
Please say whats wrong with the code. Is there anything to do for installation of GD library ?
Thanks a lot.
-
Sep 19th, 2008, 03:18 AM
#5
Re: GD Library for Beginners
You need to modify your PHP.ini file in order to enable the extension. In addition, I do not recommend that you use a script written for PHP 3. The altest version of PHP is now version 5.
Remove the call to the dl() function if you have already enabled the gd extension in the PHP.ini and read the script through and understand it as it is clear that you have simply copied and pasted it from another location into your application.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|