How to use the PHP function imagettftext to process IMG _ PHP Tutorial

Source: Internet
Author: User
Tags vector font
How to use the PHP function imagettftext to process images. Define to write ttf text to the graph. Syntax: arrayimagettftext (intim, intsize, intangle, intx, inty, intcol, stringfontfile, stringtext); return value: Array Function type: Graphic

Definition

Write ttf text to the graph.

Syntax:

Array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text );

Return value:

Array

Function types:

Graphic Processing

Description of the imagettftext function of PHP:

This function writes ttf (truetype fonts) text to an image. The parameter size is the font size. angle is the angle of the font, which is calculated clockwise. 0 degrees is horizontal, that is, the direction of three o'clock (from left to right ), 90 degrees indicates the bottom-up text. the x and y parameters are the coordinate values of the text (the origin is the upper left corner );

The col parameter indicates the color of the word. fontfile indicates the name of the fontfile, which is also a remote file. text is of course the string content. The return value is an array consisting of eight elements. The first two are the lower-left x and y coordinates, and the third and fourth are the lower-right x and y coordinates, the fifth, sixth, seventh, and eighth groups are the upper right and upper left x and y coordinates respectively. Using this function, the system needs to install the gd and freetype libraries.

Example of using the PHP function imagettftext

In this example, a 400x30 pixel black base map is created and I am number one is written in the arial vector font !! .

 
 
  1. < ?php
  2. header("content-type: image/gif");
  3. $im = imagecreate(400,30);
  4. $black = imagecolorallocate($im,
    0,0,0);
  5. $white = imagecolorallocate($im,
    255,255,255);
  6. imagettftext($im, 20, 0, 10, 20,
    $white, "/somewhere/arial.ttf",
    "i am number one !!");
  7. imagegif($im);
  8. imagedestroy($im);
  9. ?>


Compile writes ttf text to the graph. Syntax: array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text); return value: array Function type: graphic...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.