<?php
$img = imagecreatetruecolor(200, 200);
$color1 = imagecolorallocate($img, 50, 50, 50); //给图片上色
imagefill($img, 0, 0, $color1); //区域填充颜色
ob_start();
imagejpeg($img);
imagepng($im);
$fileContent = ob_get_contents();
ob_end_clean();
$img_base64 = 'data:image/jpeg;base64,' . base64_encode($fileContent);
echo '<img src="' . $img_base64 . '">'; //图片形式展示
echo '<hr>';
echo $img_base64; //输出Base64编码
?>
网友回复