图片没有显示,甚至没有显示文字。我无法找到错误。是否需要在其中添加额外的插件或库文件?
<?php
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('test.jpg');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 255, 255, 255);
// Set Path to Font File
$font_path = 'typesimp.TTF';
// Set Text to Be Printed On Image
$text = "Hello World!!";
// Print Text On Image
imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text);
// Send Image to Browser
imagejpeg($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
?>
答案 0 :(得分:-1)
您是否添加了内容类型?
//Set the Content Type
header('Content-type: image/jpeg');