【发布时间】:2018-07-19 15:28:30
【问题描述】:
我正在像这样的图像中生成一个简单的文本...
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// Set the content type header - in this case image/jpeg
header('Content-Type: image/jpeg');
// Output the image
imagejpeg($im);
// Free up memory
imagedestroy($im);
我需要输出为 base64 字符串,我尝试过 base64_encode($im) 但它对我来说不能正常工作。
谁有我可以看到的例子?
【问题讨论】:
-
$im 是一种资源,不能将其用作字符串。获取imagejpeg结果并base64encode