write text over images script error

hi everyone,

i need help to make this script work.

got files from http://alvarotrigo.com/blog/using-php-gd-library-to-write-text-over-images-using-truetype-fonts/

the demo is working but mine is not :slight_smile:

error show:
Warning: Cannot modify header information - headers already sent by …/lass.textPainter.php on line 71
Warning: imagejpeg(): Filename cannot be empty in /home…/class.textPainter.php on line 78

full my script here https://www.dropbox.com/s/vpnup95p572s1s6/textPainter.zip?dl=0

thank you.

Please post your code here inside the PHP tags. Just the section where you are writing the text over your
image. It is a simple task… Thanks!

Well, since PHPnewbie15 solved it him/herself and did not show how it is done, here is one way
for others to follow in case they need to do this…
[php]
//Set the Content Type so the image can be displayed…
header(ā€˜Content-type: image/jpeg’);

// Create Image From Existing Image File
$jpg_image = imagecreatefromjpeg(ā€˜picture.jpg’);

// Allocate A Color For The Text (White in this case)
$text_color = imagecolorallocate($jpg_image, 255, 255, 255);

// Set Path to Font File (Must be stored on server)
$font_location = ā€˜fontname.TTF’;

// Set Text to Be Printed On Image
$text = ā€œI love this picture!ā€;

// Combine Text On The Image
imagettftext($jpg_image, 25, 0, 75, 300, $text_color, $font_location, $text);

// Display the Image in the Browser
imagejpeg($jpg_image);

// Clear Memory
imagedestroy($jpg_image);
[/php]
There are hundreds of options such as opacity, colors, display angles that can be altered as needed.
This is just a simple sample… Hope it helps someone…

Sponsor our Newsletter | Privacy Policy | Terms of Service