Ich habe Bild erstellen Code in image_creator.So fügen Sie Text zu einem Bild mit PHP GD-Bibliothek
<?php
header("Content-Type: image/jpeg");
$im = ImageCreateFromGif("photo.gif");
$black = ImageColorAllocate($im, 255, 255, 255);
$start_x = 10;
$start_y = 20;
Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "text to write");
Imagejpeg($im, '', 100);
ImageDestroy($im);
?>
Die Datei für die Bildausgabe ist image.php und hat unter Code
<html>
<head>
</head>
<body>
<img src="http://localhost/image_creator.php"/>
</body>
</html>
Als ich image.php laufen, bekomme ich nur eine leere Seite. Wieso ist es so?
Zunächst einmal $ black = ImageColorAllocate ($ im, 255, 255, 255); '- das ist weiß, nicht schwarz. Haben Sie Fehler? Überprüft das Fehlerprotokoll? – iMoses
@iMoses Ich denke das '$ black' ist nur, weil er Code von php.net kopiert hat: http://php.net/manual/en/function.imagefttext.php – George
Macht es nicht richtig oder macht Sinn. Ich bin sicher, sie haben es richtig gemacht. Es ist kein Problem, nur verwirrend. Das "leere" Bild könnte nur weiß auf weißem Hintergrund sein. – iMoses