turning text into image - PHP/GD - save image

Posted by Phil Jackson on Stack Overflow See other posts from Stack Overflow or by Phil Jackson
Published on 2010-04-16T05:11:47Z Indexed on 2010/04/16 5:13 UTC
Read the original article Hit count: 240

Filed under:
|
|
|
|

Hi, I'm using this script to simply create an image from text. What I would like to know is how to save the image instead of printing straight to browser;

// an email address in a string
     $string = $post[$key];

     // some variables to set
     $font  = 4;
     $width  = ImageFontWidth($font) * strlen($string);
     $height = ImageFontHeight($font);

     // lets begin by creating an image
     $im = @imagecreatetruecolor ($width,$height);

     //white background
     $background_color = imagecolorallocate ($im, 255, 255, 255);

     //black text
     $text_color = imagecolorallocate ($im, 0, 0, 0);

     // put it all together
     $image = imagestring ($im, $font, 0, 0,  $string, $text_color);

I know its probably just one line of code at the end but im not sure which GD function to use.

Any help would be much appreciated, Regards, Phil.

© Stack Overflow or respective owner

Related posts about php

Related posts about gd