KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   J2EE  HTML  JAVA   Swing   Webtip  Forums  Lyric  Free sheet music  Ringtones

Add text on Image -Image processing in PHP

Before you start this lesson, before read the lesson PHP Image processing introduction and make sure you enable GD library.

Here is PHP code to add text on Image:


// Import the image to use
$TheImage = imagecreatefromjpeg("pig.jpg");

//Choose the Color of the text...(255,0,0 is red)
$ColorText = imagecolorallocate($TheImage, 255, 0, 0);

// printing the text:.
imagettftext($TheImage, 10, 60, 25, 110, $ColorText, "Verdana", "Happy Valentine");

// Let the browser know that it is an png image..
header("Content-Type: image/png");

// show the image in png format...(png format is clearer
imagepng ($TheImage);

The function imagecolorallocate(...) choose color for the text. Function imagettftext(...) writes text on image.

Explanation for each parameter in imagettftext($TheImage, 10, 60, 25, 110, $ColorText, "Verdana", "Happy Valentine");:

  • $TheImage : the image
  • 10 : the font size. Depending on your version of GD, this should be specified as the pixel size (GD1) or point size (GD2).
  • 60 : The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text.
  • 25 and 110: define the upper-left corner of the first character.
  • $ColorText: color of text
  • "Verdana": text font;
  • "Happy Valentine": is the text we want to write on image;

Processed image sample

Here is the sample of the above code:

php image processing, add text on image


PHP Calendar
Comprehensive PHP Web Calendar
Configurable PHP Calendar
PHP Calendar
PHP Image Processing
PHP grahic softwares
PHP create real-time dynamic chart
create antispam image(image verification)
Add water mark to image
PHP Image processing introduction
Add text on Image
Create thumbnail for image
Create image from text on fly
PHP code sample
PHP create dynamic PDF with FPDF
PHP create dynamic PDF with PDFLib
PHP create dynamic PDF with ClibPDF
Improved PHP configurable hit counter
Install phpMyAdmin,MySql, PHP
PhpMyAdmin export/import data
A simple PHP RSS feed reader
PHP include (SSI)
Working with Forms
PHP formmail Generator
Using phpMyAdmin Create Database
Insert Form Data into Database
Retrieve data from Database
Retrieve multiple records
Batch insert text using phpMyAdmin
Using phpMyAdmin insert binary file
Insert binary file using PHP code
Using form insert binary file into MySQL
Retrieve binary file from MySQL
Image hosting business in minutes
Send HTML mail in PHP
Send bulk emails in PHP
Polling/Rating System in PHP
Polling/Rating System in PHP(radio button)
Check visitor's IP address
Check reciprocal link
PHP tutorial
What is PHP?
Install PHP on Windows XP (part1)
Install PHP on Windows XP (part2)
PHP open and closing tags
PHP types
Logic Structures
Include files
Set cookie and delete cookie
Most often used MySQL functions



Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © All rights reserved(new). Privacy|Copyright
designed by

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer