Home > php教程 > php手册 > php 文本文字创建生成图片

php 文本文字创建生成图片

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:23:12
Original
1573 people have browsed it

php 文本文字创建生成图片

现在有不少人要生成文本图像。 PHP的GD库允许我们这样做就是这样。这里我们给出一个简单的方法,是把图像网页上使用的电子邮件地址。有人说,这有助于保持电子邮件收割机远,但其光学字符识别这仍然是可能的。

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


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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template