php生成二维码

  • php7
  • 预装Image、QrCode依赖

1、直接生成二维码

//format:格式
//size:大小
//margin:边距
//generate:参数
$info = 'zhe shi qrcode';
$qrcode = QrCode::format('png')->size(1000)->margin(1)->generate($info);
$qrcode = Image::make($qrcode)->widen($erm_width);
//生成二维码
$img->insert($qrcode, 'bottom-left', '260', '458');
$save_path = '保存的地址路径';
$img->save($save_path);

  

2、二维码放置到背景图上

$hb_mb = "背景图的地址";
$img = Image::make($hb_mb);
$info = 'backgroup qrcode';
$qrcode = QrCode::format('png')->size(1000)->margin(1)->generate($info);
$qrcode = Image::make($qrcode)->widen($erm_width);
//生成二维码
$img->insert($qrcode, 'bottom-left', '260', '458');
$save_path = '保存的地址路径';
$img->save($save_path);

3、二维码和参数同时放到背景图上

$hb_mb = "背景图的地址";
$img = Image::make($hb_mb);
$info = 'backgroup qrcode';
$qrcode = QrCode::format('png')->size(1000)->margin(1)->generate($info);
$qrcode = Image::make($qrcode)->widen($erm_width);
//生成二维码
$img->insert($qrcode, 'bottom-left', '260', '458');
//值
$name_left = '283';
$name_top = '625';
$name_color = '#DC9865';
$username = '这是一张带二维码和值的图';
//合并
$img->text($username, $name_left, $name_top, function ($font) use ($name_color) {
    $font->size(20);
    $font->color($name_color);
});
$save_path = '保存的地址路径';
$img->save($save_path);

你可能感兴趣的:(php,laravel,php,二维码)