I'm probably missing something really obvious here, but I can't work out how to get a GD created image to save to a (web) folder on the server.

I.e. a image is created by GD, and I want to save the GD output as something.gif

I dont mind that the image is written over every time the script is called, so it can't be that hard 🙁

At the moment, I just have:

// create image and colours

$im = ImageCreate(400, 14);

$red = ImageColorAllocate($im, 255, 0, 0);

$black = ImageColorAllocate($im, 0, 0, 0);

// fill image

ImageFill($im, 0, 0, $red);

// write string at (210,30) in black

ImageString($im, 2, 2, 0, $textfrompost, $black);

ImageColorTransparent($im, $red);

// release image

ImagePNG($im);

Can anyone help?

Cheers!

Joel

    <?
    
    // create image and colours
    
    $im = ImageCreate(400, 14);
    
    $red = ImageColorAllocate($im, 255, 0, 0);
    
    $black = ImageColorAllocate($im, 0, 0, 0);
    
    $textfrompost = "This is text";
    
    // fill image
    
    ImageFill($im, 0, 0, $red);
    
    // write string at (210,30) in black
    
    ImageString($im, 2, 2, 0, $textfrompost, $black);
    
    ImageColorTransparent($im, $red);
    
    // release image
    
    ImagePNG($im);
    ImagePNG($im, 'Upload/test_image.png');
    
    
    ?>
    

    Where the directory 'Upload' gives permission to everyone to read write and execute (CHMOD 777).

    Cheers,
    C

      Write a Reply...