CF TextImage Class

CF TextImage Class is a small but useful PHP script that can generates a image from a string of text using a True Type Font (ttf). This script has some simple uses such as a replacement for JavaScript cufon library when JavaScript is not available, a replacement for Flash based text or displaying a email address that cannot be programmatically found. This can help to reduce the possibility of your email address being picked up by web crawlers and used for junk mail.

How To Use This Text to Image Class?

There are many ways you can use this class,
  • Dynamic Image Generation
  • include class - Image HTML Code Generation
  • include class - PHP Image Resource
Before we set it to work, though, you will need to customize some of the default settings. You can find the default settings in the construct function of the class, there are 4 you will most likey edit for your specific purpose.

->set['fontName'] = 'ChampagneAndLimousines'// preferred TTF font
$this->set['fontSize'] = 30// preferred font size
$this->set['fontColor'] = 6// preferred font color
$this->set['userKey'] = md5('cftextimage'); // md5 sign of parameters

The 3 font default setting can be overridden dynamically when making the image, All other default settings and userKey can not be updated dynamically.
  • fontName: this must be set to the True Type (TTF) font name with out the extension (.ttf).
  • fontSize: the size of the font in points.
  • fontColor: is a hexadecimal color codes that indicate the color of the text.

The user Key is used like a password, the script uses a MD5-based authorization to avoid image generation by unauthorized users.
  • userKey This holds your userKey this help.

Where can you use it?

The first and easiest way to use this script is to call the class dynamically. Dynamic Image Generation is when the rating of a images is done on the fly. This Text to Image script will deliver a dynamic PNG image to the browser whenever it’s asked to.

To generate image with the text 'Hello World' on it, using the font LaurenScript.ttf with a size of 25px and the color #3aa3ff, you would call it like: <img alt="Hello World" title="Hello World" src="./cftextimage/cftextimage.class.php?text=Hello+World&amp;size=25&amp;font=LaurenScript&amp;color=3aa3ff&amp;a=8a3b93b3fc699ab34644e5e376a8df5a" />
Hello World Note parameter 'a=6c39e9099f6dfebf2f88172cf204e69a'. '6c39e9099f6dfebf2f88172cf204e69a' is a result of md5(userkey.'Hello World253aa3ffLaurenScript'): concatenation of secret key, text, font size, font color and font name.
You could use a helper function to set script arguments, like 'imgParams' below: <?php
// your user key
$userkey md5('cftextimage');

// returns parameters
function imgParams($text$size=null$font=null,$color=null){
$p '?text='.urlencode($text).
<img src="./cftextimage/cftextimage.class.php<?php echo imgParams('Hello World'25'LaurenScript','3aa3ff');?>" title="Hello World" alt="Hello World">

include class - Image HTML Code Generation

The second way to use this script, is by including the class in to your file. Using it this way you do not need to send the user key to the script and the script will out put the image HTML tag for you. <?PHP
include './cftextimage/cftextimage.class.php';
$img = new imageText();
$img->imageSettings('example 2'25,null,'3aa3ff');

The output would be:
<img title="example 2" alt="example 2" src="">

include class - PHP Image Resource

The last way to us this class is by having it output a PHP image Resource, so you can use the image with other php image script with out having to reopen the image from disk.
The example below shows you how you can use this to rotate the image: <?PHP
include './cftextimage/cftextimage.class.php';
$img = new imageText();
$img->imageSettings('example 3'25,'ChampagneAndLimousines','3aa3ff');
$im $img->makeImage('resource');

$im imagerotate($im$degrees0);
header('Content-type: image/png');

The output would be:
example 3 Rotate 180

System Requirements

  • Apache Web server (recommended) or IIS
  • PHP version 4.3 or greater
  • PHP extension GDLib


Download : CF TextImage Class
If you find any bugs or if you need any help please feel free to post a comment on the forum and I will answer you as soon as possible.

Other Tools

CSS3 Transform
This on-line tool allows you to experiment with the CSS Transforms for Safari, Chrome,...
lorem Ipsum Text Generator
The Lorem Ipsum Tode Generator creates place holder content using Latin passages.
Copyright Generator
This free on-line tool will help you generate a copyright notice that will always be up to...

Forum Topics

acquire top quality essays on the cheap!
If you are a student who is with limited budget, then you need cheap essay writing service to write my paper...
Latest Cisco 300-115 Exam Study Guide
The IT industry is the future of this world. In the previous decade, it has taken over the job market,...
Tips for Writing an Effective Application Essay
When you observe to college, you’ll need to complete an essay as part of your software. This is your...
ImgLink.Me Free Image hosting
This is great software! Amazing. This is my site, feel free to host your image.. We will be free...
Two Issues - Deleting images and Dashboard hanging
Issue 1 I can't delete images using the admincp option. This is a serious fault if the site is spammed it...