分享一个码云上挺好用的海报合成

码云

$config = array(
        'bg_url' => __DIR__ . '/../../' . $bg1,//背景图片路径
//    'text' => array(
//        array(
//            'text' => $title,//文本内容
//            'left' => 290, //左侧字体开始的位置
//            'top' => 680, //字体的下边框
//            'fontSize' => 38, //字号
//            'fontColor' => '234, 202, 161', //字体颜色
//            'angle' => 0,
//        ),
//        array(
//            'text' => $sub_title,
//            'left' => 150,
//            'top' => 750,
//            'width' => 500,
//            'fontSize' => 16, //字号
//            'fontColor' => '141, 142, 144', //字体颜色
//            'angle' => 0,
//        ),
//        array(
//            'text' => $activity_title,
//            'left' => 190,
//            'top' => 840,
//            'width' => 400,
//            'fontSize' => 31, //字号
//            'fontColor' => '234, 202, 161', //字体颜色
//            'angle' => 0,
//        ),

//    ),
        'image' => array(
//        array(
//            'url' => $person_img_sl,
//            'stream' => 0,
//            'left' => 300,
//            'top' => 390,
//            'right' => 0,
//            'bottom' => 0,
//            'width' => 180,
//            'height' => 180,
//            'radius' => 0,
//            'opacity' => 100
//        ),
            array(
                'url' => '',
                'stream' => $qrCodeData,//数据流
                'left' => 503,
                'top' => 1128,
                'right' => 0,
                'bottom' => 0,
                'width' => 120,
                'height' => 120,
                'radius' => 0,
                'opacity' => 100
            ),
        )
    );

 poster::setConfig($config);
//设置保存路径
    $bg1_path = __DIR__ . "/img/poster_bg1_{$sharer_id}.png";
    $res = poster::make($bg1_path);
    poster::clear();
//或者直接显示在浏览器上
$res = poster::make();
header("content-type:image/png");
   echo $res;

By cc

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注