Hi all,
I am having a problem with this and I just can’t get my head round it.
Any way I was given some php to display text in an image "good stuff"
But and the but is!!!, for some rezone It does not work when I load it.... I have a version of this that does not load a font and works well, but the wife (the protect is for her) wants the text I a certain type of font on her image.
I have read that I could use loadfont, or something like that but being new to this I am nut sure how to implement it into the code.
would one of you be as so kind as to help me out one this one e.g amend my code for me please and a pointer as to what is goning wrong.
Many thanks
Paul
<?
function ImageStringWrap($image, $font, $x, $y, $text, $color, $maxwidth)
{
// $font = ImageLoadFont("ITCKRIST.TTF"); // has no effect
$fontwidth = ImageFontWidth($font);
$fontheight = ImageFontHeight($font);
if ($maxwidth != NULL) {
$maxcharsperline = floor($maxwidth / $fontwidth);
$text = wordwrap($text, $maxcharsperline, "\n", 1);
}
$lines = explode("\n", $text);
while (list($numl, $line) = each($lines)) {
imagettftext($image, 20, -2, $x, $y, $color, 'ITCKRIST.TTF', $text); // returns nothing apart from the image
// ImageString($image, 20, $x, $y, $line, $color); //imagestring will work but not load the font.!!!
# $y += $fontheight;
}
}
header("Content-type: image/jpeg");
$string = $_GET['text'];
$im = imagecreatefromjpeg("einsteinshow.jpg");
$alpha = 95;
if (strlen($string) < 23) $alpha = 60;
if (strlen($string) > 90) $alpha = 105;
$color = imagecolorallocatealpha($im, 255, 255, 255, $alpha);
ImageStringWrap($im, 5, 140, 150, $string, $color, ImageSX($im)-300);
imagejpeg($im);
imagedestroy($im);
?>
this is the PHP info from my host server....
gd
GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled