我正在处理一个小型 php 项目。在创建文本生成图像时。拿了一些示例代码,累了。
<?php
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>
我做了一些改变,效果很好。当我尝试将此 php 文件插入到其他 html 文件中时,使用它会导致图像损坏。我该如何解决这个为什么会发生。