×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

GD Library add text to image

GD Library add text to image

GD Library add text to image

(OP)
Hi. Has anyone had any success with using the GD library to write text on an image. I have trawled the 'net and tried various methods but none will work. I have tried them all on 4 separate servers - all with GD enabled, FreeType Support enabled, FreeType Linkage  with FreeType, GetText Support enabled (if they are relevant). I have been able to create a border around an image but the text on image is still eluding me.
Any suggestions will be greatly appreciated.

Cheers

RE: GD Library add text to image

what errors are being reported?  i don't remember this being difficult but have not tried for some time.

RE: GD Library add text to image

(OP)
No errors, just the image remains unchanged.  

RE: GD Library add text to image

ok then. what code have you tried so far?   

RE: GD Library add text to image

this, for example, works fine for me

CODE

<?php

//get tektips logo
$im = imagecreatefromgif('http://www.tek-tips.com/images/logo.gif');

//get the image size
$w = imagesx($im);
$h = imagesy($im);

//now create the text on a new canvas (i've used identical sized canvases but in practice you probably will not want to do so)
$text = imagecreatetruecolor($w, $h);
//place some text at the top left
imagestring($text, 5, 0, 0, 'Tek-Tips', 0x0000FF);


// merge the two canvas
//set opacity to 50%
imagecopymerge($im, $text, 0, 0, 0, 0, $w, $h, 50);

// output the image
header('Content-Type: image/png');
imagepng($im);
imagedestroy ($text);
imagedestroy($im);
?>

RE: GD Library add text to image

(OP)
Yay it works.

Thankyou....Your blood is worth bottling.

Cheers

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close