参考: https://blog.csdn.net/qq_26245325/article/details/79918945
安装php gd库,并重启apache2:
sudo apt-get install php5-gd
sudo service apache2 restart
<?php
//需要开启gd库
header("Content-type: image/png");
$im = imagecreatetruecolor(512, 512)
or die("Cannot Initialize new GD image stream");
$white = imagecolorallocate($im, 255, 255, 255);
for ($y=0; $y<512; $y++) {
for ($x=0; $x<512; $x++) {
if (rand(0,1) === 1) {
imagesetpixel($im, $x, $y, $white);
}
}
}
imagepng($im);
imagedestroy($im);
?>
离线
php生成二维码用的就是这个吧。
离线