Web-development informational articles

Pim team case study: creating text belongings with php and gd - web-development


See how you can conceive decorative personal property on text with PHP and GD - drop shadows, arcs, fonts and colors.


A-tec Signs and Sraphics Inc. launched a web site with the idea to sell decals online. To attain advance customers ineterest the website had to integrate online decal builder. The circle is present also decals for vehicles which brought some aspect chuck to the draftsman like having the decal text revolving arround 4 types of arcs.


  • Provide users with preview area

  • Allow visitors to elect font and color

  • Allow accumulation drop shadow and selecting drop shadow color

  • Allow rotary the text into arcs

  • Real Time calculating


Because of the need for escalating customers appeal we had to think about not for accurate math formulas when presentation the graphs in the preview area, but for the associates who will look at them.

As we will reaveal below, there were few tribulations going arround human appreceptions for a little 'perfectly smooth' and the matchematical accurate figures.


We were going to extensively use PHP GD collection for the text effects. It provided easy altering of fonts and colors, addition drop shawdows and rotating the texts.

We had also to coin color palletes which to arrive on the scene when user click and cease to exist when color is select (You can in my opinion try the decals creating here). Using buried layers and javascript was assumed to do the work.

The main conundrum in this site was to build 4 types of arcs so when the user selects one of them the text is bent arround imaginary arc (like in the vector graphical softwares). We were going to study Bezie's formulas and construct these arcs with its help.


PIM Team Bulgaria had the task to build the full functional online decals draftswoman with the subsequent features:

- Decal background

Some users were alleged to have their decals positioned on dyed background. We had to allow the preview area to be painted in a elected background. First we produced the image in temp folder:

// the name of destination image

$dest='decals/'. time(). '. jpg';

//the background

imagefilledrectangle ( $im, 0, 0, 590, 60, $colors[$_POST['bcolors']]);

$colors array contains the existing color which are stored by the executive in the database.

Thus, when the visitor selects a backdrop it is accepted as parametter to imagefilledrectangle function.

- Font selection

Users must be able to decide on fonts for their forthcoming decals. Aware that we can't care about all the fonts will be free on all visitor's computers we had to upload them on the web ma?tre d' directory.

We permissible the admin to cope the fonts, adding up their names and uploading files in admin area.

The fonts in the choose box came from the database. Preferred font was accepted in the call to imagettftext funtion which is doodle on the beforehand fashioned image.

- Color Selections

The color selections had to be a palettes which arrive when user clicks and depart when color is selected. The palette had to look as a table with flag and these ensign are also distinct in the

admin area so they had to come dynamicly. We had to seed a static javascript do with dynamic content.

We bent a PHP cycle which was captivating the flag from the folder and then creating a line for HTML table. This table is then approved to a javascript affair which creates the palletes with the help of clandestine layers:

function showTable(table)


mouseX = window. event. x + document. body. scrollLeft+25;



var content="";

var y=460;




var content="";

var y=690;




var content="";

var y=810;


document. getElementById('tabler'). style. pixelLeft=mouseX;

document. getElementById('tabler'). style. pixelTop=y;

document. getElementById('tabler'). style. visibility='visible';

document. getElementById('tabler'). innerHTML=content;


Of course, once the user choice the much loved color we had to hide the pallette:

function setColor(elid,color,fromid,shc)


document. getElementById(elid). value=color;

document. getElementById('tabler'). style. visibility='hidden';


Thus we bent nice palettes which arrive on the scene and depart on a definite click and don't take much space on the screen.

- Drop Shawdows

The decals accessible has the aptitude to have a drop shadow added so we had to add this alternative to the online builder. PHP but didn't accessible a nice do for that. We bent a course of action which draws the texts twice - once the creative 100% drenched text and once the shadow with a percentage of the color and apposite displacement. Of avenue the shadow was drawn on the image ahead of the main text.

@imagettftext($img, 20, $gr[$i], $x+$dx, $ys[$i]+$dy, $scolors[$shadowcolor], "fonts/". $_POST['fonts'],$word[$i]);

- Arcs

The main badly behaved came when we had to 'rotate' the texts thru arcs. First we formed achieve Bezie funtion which to draw the curves and alter the correspondence above them. But what a alarm - the curves looked absolute alone, but when we adjusted the calligraphy above them they seemed rough.

After studying this catch we realised that the rough broadcast decree and the disability to antialise the imagery wouldn't allow us to construct nice arcs. We were eminence alongside impossible to solve problem.

We categorical to coin few arcs with a graphical software (CorelDraw) and to see what could be wrong.

We noticed that Corel's curves were looking great after they are manually adjusted. But you can't just leave the agenda to conceive absolute curves automaticly. A human eye was desired to judge when a curve looks right and when not.

We got a absolutely assorted direction. There wasn't an entire affair to help us. The answer we found was to 'manually' amend each letter. We fashioned a course of action with cases which were adjusting each dispatch on the apposite place and with apt rotation depending on how long was the text. It worked!

We bent 2 arrays for each arc type - one array with the positions and one array with the rotations.

The rest was simple:




if($start%2) $start+=1;








//making the arrays


You can go on the atec's site and try the arcs we achieved (http://atecsigns. com/decal/step_1. php).


Now A-tec Sings's web engineer creates achieve decals with graphs, calculates the price and allows you to add the decals to your shopping cart and chgeckout (the shopping cart software is also produced by PIM Team Bulgaria).

The draftsman allows the visitor to construct the beloved decals with any color, dropped shadow, backdrop and shape, to preview it and to determine the cost for altered sizes and quantities.

The website and designer were promoted with considerable radio marketing company. At that time it was the only decal draftsman which permitted creating texts arround arcs.


  • Use GD to build text effects

  • Do not fail to remember that you can build you own functions for what GD does not offer

  • Do not at all times examination for math absolute formulas. The graphical personal property are future to the human eye

  • Load fonts in the server

  • Use javascript and covert layers to do great flexibility

About The Author

Bobby Handzhiev is a chief developer in PIM Team Bulgaria

http://pimteam. net

admin@pimteam. net


KPS3 Hires Vivek Bhardwaj as Web Developer  Nevada Business Magazine

Web development company to move to downtown Battle Creek  MiBiz: West Michigan Business News

Junior Web Developer  Charlotte Agenda

Developed by:
home | site map
goldenarticles.net © 2019