Sono molte ore che sto ancora cercando risposta a questo problema .. Tutte le soluzioni che trovo sono intorno a prendere il nome del font ma sono abbastanza sicuro che questo non è il mio problema.PHP - imagettftext non funziona e GD installato
Sembra GD è installato
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)
}
Sopra potete vedere il mio supporto GD. La mia versione PHP è 5.3 e sto funzionando su Linux.
Ho provato alcuni esempi di codice diversi da diversi siti Web e nessuno funziona. ImageString funziona per me, ma ho bisogno di ottenere imagettftext di lavorare ..
Questo è l'ultimo codice che ho provato ora-
<?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);
?>
Risultato:http://www.7679679.com/app/test-ansi.php
Se si imposta intestazione ... poco prima imagepng, quello ErrorMsg cosa si ottiene? – michi
php ti dà qualche errore/avviso? Cosa restituisce la funzione 'imagettftext'? Dovrebbe restituire array di punti o falso in caso di errore. prova '$ text_result = imagettftext (...); if ($ text_result === false) {echo ("ERROR");} else print_r ($ text_result); '. Un'altra cosa, quando stai riempiendo la tua immagine appena creata, hai lasciato un pixel in altezza e riempito solo 29 pixel di 100 in larghezza, è apposta? – Buksy
come hai stampato quell'array ??? – Saswat