Results 1 to 2 of 2

Thread: PHP GD library
      
   

  1. #1
    pipesportugal's Avatar
    pipesportugal is offline Second Lieutenant
    Join Date
    Jul 2007
    Location
    Oporto - Portugal
    Posts
    129

    Default 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

  2. #2
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default 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
    http://us.php.net/manual/en/ref.image.php

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49