Hello!
I want to load text from a .txt file on the web and put it on to an image. How can I do that in php?
Thanks.
Hello!
I want to load text from a .txt file on the web and put it on to an image. How can I do that in php?
Thanks.
http://uk.php.net/image
Any good?
depends if you want it added directly to the image or just to appear on top of the image. The first requires the use of the GD library in PHP, the second can be done with some simple CSS
that will write your text to a png image with red font and transparent background.PHP Code:
<?php
$handle = fopen("filename.txt", "r"); //opens text file
$content = fread($handle, filesize("filename.txt")); //reads content of file into $content
header("Content-type: image/png");
$im = @imagecreate(130, 20)
or die("Cannot Initialize new GD image stream"); //creates image with sizes (x, y)
$background_color = imagecolorallocate($im, 255, 255, 255); //set bg colour
$text_color = imagecolorallocate($im, 233, 14, 91); //set text color
imagecolortransparent($im, $background_color); //make bg transparent
imagestring($im, 4, 5, 5, $content, $text_color); //write the text string to image
imagepng($im); //make image
imagedestroy($im);
fclose($handle);
?>
Col
There are currently 1 users browsing this thread. (0 members and 1 guests)