Home > Backend Development > PHP Tutorial > PHP text text creation and image generation_PHP tutorial

PHP text text creation and image generation_PHP tutorial

WBOY
Release: 2016-07-20 11:06:52
Original
1105 people have browsed it

php text text creation to generate images

Many people now want to generate text images. PHP's GD library allows us to do just that. Here we give a simple method that is to put an image on a web page using an email address. Some say this helps keep email harvesters away, but with its optical character recognition this is still possible.

// show the correct header for the image type
header("Content-type: image/jpg");

// an email address in a string
$string = "email@example.com";

// 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);

// and display
imagejpeg ($im);
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444985.htmlTechArticlephp Text text creation to generate images Now many people want to generate text images. PHP's GD library allows us to do just that. Here we give a simple method, which is to put the image network...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template