How do I create a custom image for download?

Discussion in 'PHP' started by Valdor, Sep 23, 2009.

  1. #1
    Now then, I have an image on a website that members can use on their own site to show they are members of my site.

    Each member has a unique membership number.

    How do i create this image with the members number on it?.

    Here is the scenario:
    Member signs up and is member number 12345, when this member is logged into my site he is able to download the image that has their membership number on it auto created from the blank stock image.

    Thanks
     
    Valdor, Sep 23, 2009 IP
  2. firemarsh

    firemarsh Peon

    Messages:
    153
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    firemarsh, Sep 23, 2009 IP
  3. Valdor

    Valdor Well-Known Member

    Messages:
    450
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Thanks for the link, I got it working using this:
    
    <?php
    header("Content-Type: image/jpeg");
    //open up the image you want to put text over
    $im = ImageCreateFromGif("image.gif"); 
    $fonttype = "font.ttf";
    //The numbers are the RGB values of the color you want to use
    $red = ImageColorAllocate($im, 255,0,0);
    //The canvas's (0,0) position is the upper left corner
    //So this is how far down and to the right the text should start
    $start_x = 97;
    $start_y = 230;
    //This writes your text on the image in 32 point
    Imagettftext($im, 32, 0, $start_x, $start_y, $red, $fonttype, 'text');
    //Creates the jpeg image and sends it to the browser
    //100 is the jpeg quality percentage
    Imagejpeg($im, '', 100);
    ImageDestroy($im); 
    ?>
    
    Code (markup):
     
    Valdor, Oct 3, 2009 IP