讨论数量:
画出来的
public function createQrCode($str)
{
$qrCode = new QrCode($str);
$qrCode->setSize(310); //设置大小
$path = config('image.img_conf.path');
$qrCode->setWriterByName('png')
->setEncoding('UTF-8')
->setErrorCorrectionLevel(ErrorCorrectionLevel::LOW)
->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0])
->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255]);
// Save it to a file
$resultpath = $this->mkdirs(storage_path($path.'/qrCode'));
$qrCode_img = uniqid() . '.png';
$qrCode->writeFile($resultpath.'/'.$qrCode_img);
return $qrCode_img;
}
你可以了解下 Intervention Image
https://github.com/Intervention/image
http://image.intervention.io/
简单示例如下
//没有文字的底图
$img = Image::make(storage_path('/app/share_images/share_image.png'));
//在底图上添加文字
$img->text(“文字文字文字文字”, 200, 90, function ($font) {
$font->file(storage_path('/app/fonts/msyhbd.ttf')); //字体
$font->size(18); //大小
$font->color('#666666'); //颜色
$font->align('center');
$font->valign('top');
});
推荐文章: