[Wolves] GD add text to picture

Chris Ellis chris at intrbiz.com
Wed Nov 20 15:26:57 UTC 2013


On Wed, Nov 20, 2013 at 3:08 PM, Wayne <waynelists at machx.co.uk> wrote:

> Hi,
>
> Why isn't this working (well it creates image but no text!)
>
> $origImage from elsewhere..... then
>
>
> /* black for the text */
> $black = imagecolorallocate($origImage, 0, 0, 0);
>
> /* put the text on the image */
> imagettftext($origImage, 72, 0, 0, 0, $black,
> "/home/j9accomm/public_html/j9photobooth/arial.ttf", "Hello World");
>
> /* save the image */
>
> imagejpeg($origImage,'uploads/thumbs/'."result.jpg");
>
>
>
> i've tried all manner of font paths etc in the font bit to no avail.
>
>
> cheers


Hi Wayne

>From a quick glance at the docs:  http://us2.php.net/imagettftext

The x and y co-ordinate is the baseline of the text, as such I suspect you
are drawing the text off the top of the image.

Try:

imagettftext($origImage, 72, 0, 0, 72, $black,
"/home/j9accomm/public_html/j9photobooth/arial.ttf", "Hello World");


Failing that, try isolating out a test case to provide your code.

Regards,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/wolves/attachments/20131120/cf304cf4/attachment.html>


More information about the Wolves mailing list