Results 1 to 5 of 5

Thread: GD Library for Beginners

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question GD Library for Beginners

    I download the GD library but I connot use it. Please show me how to use this.

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    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.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: GD Library for Beginners

    Quote 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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question 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:clauer@citeweb.net) 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 = -* (pi()/2) ; // origin is -PI/2
    $hourrad = -* (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($im153255204);

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

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width