I use this script to just create an image from text. I would like to know how to save the image, and not print directly in the 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 it, probably only one line of code at the end, but I'm not sure which GD function to use.
Any help would be greatly appreciated, Regards, Phil.
EDIT:
I tried the following, but just got a black box with beams;
// 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 imagestring ($im, $font, 0, 0, $string, $text_color); imagepng($im, 'somefile.png'); imagedestroy($im);