PHP GD library

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • pipesportugal
    Second Lieutenant

    • Jul 2007
    • 130

    PHP GD library

    Hello everyone,

    I would very much appreciate if someone could post here some examples of how to use the PHP GD library in order to create squares/rectangles and other geometric figures dinamically.

    I will also make some trials and I will then post them here to share with everyone.

    Thanks in advance,
    pipesportugal
  • Watdaflip
    Major General

    • Sep 2005
    • 2116

    #2
    Re: PHP GD library

    PHP Code:
    // Create new image
    $image imagecreatetruecolor(200200);

    // Define the colors in RGB format, values of each being 0-255
    $red     imagecolorallocate($image25500);
    $green     imagecolorallocate($image02550);
    $blue     imagecolorallocate($image00255);

    // Create a rectagle with a top left corner at point 10,10 and bottom right at 40,40
    imagefilledrectangle($image10104040$red);
    imagefilledellipse($image1001005050$green);
    imagefilledrectangle($image30308080$blue);

    // Save the images
    imagejpeg($image"test.jpg"100);

    // Destroy image, removing it from memory
    imagedestroy($image); 
    Simple image script, it will create two rectangles and a circle. The process of creating an image is

    1) Create a blank image or create a copy of an existing one
    2) Define colors
    3) Do whatever modification to the image be it adding shapes, text, etc
    4) Save the image
    5) Destroy the image, that is the copy of the image that is in memory on the server.

    Here's a link to all of the GD functions
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    I hope this helps, feel free to ask if you have any questions, I will help if I can

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment

    Working...
    X