PHP图像文本写标题

时间:2017-01-02 13:56:46

标签: php image

我想在这张照片上写一些文字

enter image description here

但我不能因为每次我添加标题发生这个

enter image description here

但我读到我必须添加标题,因为如果我不添加标题发生错误,抱歉坏英语..

<?php
  //Set the Content Type
  header('Content-type: image/jpeg');

  // Create Image From Existing File
  $jpg_image = imagecreatefromjpeg('sunset.jpg');

  // Allocate A Color For The Text
  $white = imagecolorallocate($jpg_image, 255, 255, 255);

  // Set Path to Font File
  $font_path = 'font.TTF';

  // Set Text to Be Printed On Image
  $text = "This is a sunset!";

  // 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 个答案:

没有答案