NYCPHP Meetup

NYPHP.org

[nycphp-talk] text overlay on graphic

Ajai Khattri ajai at bitblit.net
Fri Sep 10 13:04:25 EDT 2004


John Lacey wrote:

> I'm looking for input on taking any image format and overlaying 
> customized text that a client enters for "proofing" a product order on 
> a website.
>
> Before I launch into some research, this strikes me as doable with php 
> and gd... any experience on this?


I have done this using GD with PHP. One thing to watch out for is to 
remember where the origin is and also when drawing text, remember that 
the coordinates used are the coordinates of the left side of the 
baseline of the text - in other words there will be letters that will 
fall below as well as above the baseline and this needs to be taken into 
account when drawing text.

The function I wrote overlayed text onto a banner - I would calculate 
the text size inside a loop that dropped the point size on each 
iteration, exiting the loop only when the text would fit inside the 
banner (I also centered the text before drawing).

-- 
Aj.
Systems Administrator / Developer




More information about the talk mailing list