Es ist lange Stunden, dass ich noch auf der Suche nach einer Antwort auf dieses Problem bin .. Alle Lösungen, die ich finde, sind um den Namen der Schriftart zu fangen, aber ich bin mir ziemlich sicher, das ist nicht meine Problem.PHP - imagettftext funktioniert nicht und GD installiert
Es ist wie GD sieht ist installiert
array(11) {
["GD Version"]=>
string(27) "bundled (**2.0.34 compatible**)"
["FreeType Support"]=>
bool(false)
["T1Lib Support"]=>
bool(false)
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
Above Sie meine GD-Unterstützung sehen. Meine PHP-Version ist 5.3 und ich verwende Linux.
Ich habe einige verschiedene Codebeispiele von verschiedenen Websites ausprobiert und keine funktioniert. image ist für mich arbeiten, aber ich brauche imagettftext zur Arbeit zu kommen ..
Dies ist der letzte Code, den ich jetzt-
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 100) or die("Can't create image!");
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing';
// Replace path by your own font path
$font = 'arial.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, 'arial.ttf', $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, 'arial.ttf', $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
Ergebnis versucht haben: Siehttp://www.7679679.com/app/test-ansi.php
Wenn Sie Header gesetzt zu bekommen ... kurz vor imagepng, was errormsg bekommen Sie? – michi
Gibt es bei PHP irgendwelche Fehler/Hinweise? Was gibt die Funktion "imagettftext" zurück? Es sollte Array von Punkten oder falsch bei Fehler zurückgeben. probiere '$ text_result = imagettftext (...); if ($ text_result === false) {echo ("FEHLER");} else print_r ($ text_result); '. Eine andere Sache, wenn Sie Ihr neu erstelltes Bild füllen, haben Sie ein Pixel auf Höhe und füllte nur 29 Pixel von 100 auf Breite, ist das absichtlich? – Buksy
Wie hast du dieses Array gedruckt? – Saswat