PHPackages                             xuxuxuzw/poster - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xuxuxuzw/poster

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xuxuxuzw/poster
===============

a poster generator

0.1.0(6y ago)52831MITPHP

Since Mar 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/xuxuxuzw/poster)[ Packagist](https://packagist.org/packages/xuxuxuzw/poster)[ RSS](/packages/xuxuxuzw-poster/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (6)Used By (0)

 poster（海报）
============

[](#-poster海报-)

 php快速生成海报

\## 安装 ```
$ composer require xuxuxuzw/poster
```

示例
--

[](#示例)

```
 		$background_image_path = "./resource/background.jpg";//定义海报背景图路径

        $font_path = './resource/SourceHanSans-CN-Regular.ttf';//定义海报使用的文字字体路径

        //定义用户头像信息
        $head_portrait = [
            'width' => 120,
            'height' => 120,
            'img_path' => './resource/avatar.png',
            'is_circular' => true
        ];

        //定义用户昵称信息
        $nickname = [
            'user_name' => 'xzw',
            'font_path' => $font_path,
            'font_size' => 18,
            'color' => '#3399ff'
        ];

        //定义海报保存位置(如果直接浏览器输出可不用)
        $image_save_path = "./images/test.png";

        #获取带logo的二维码图片资源
        //创建海报
        $qrcode = new Xuxuxuzw\Poster\Poster(250, 250);
        //获取logo图片在二维码的坐标（也可以自己写具体的坐标值，这里提供了 左上角、左下角、右上角、右下角、中上、中心、中下七个点坐标的快速获取）
        $logo_xy = $qrcode->getPosition(0, 50, 50)[Poster::POSITION_CENTER];
        //这里采用链式，可以直接在后面追加
        $image = $qrcode->addQrCode('https://me.csdn.net/xzw1315915745', [250, 250], Poster::POSITION_CENTER)//添加一个二维码
        ->addImage('./resource/logo.jpg', $logo_xy, [50, 50])//添加一个图片(logo)
        ->getImageResource(); //这里的二维码不单独使用，所以直接获取图片资源回来即可，生成海报使用 render 方法

        #生成一张海报
        //创建海报
        $poster = new Xuxuxuzw\Poster\Poster(800, 1422);
        //这里使用到了用户头像和昵称，直接使用 addUser 方法
        //ps：头像和昵称可以一起展示，也可以单独展示，一起展示时可以设置昵称在头像的右侧和下方，默认昵称在头像右侧
        $poster->user_name_location_direction = Poster::USER_NAME_LOCATION_RIGHT;//设置昵称在头像右侧

        //快速获取二维码图片在海报的坐标，这里是获取右下角坐标
        $qrcode_xy = $poster->getPosition(20, 250, 250)[Poster::POSITION_RIGHT_BOTTOM];

        $poster->addImage($background_image_path, [0, 0], [800, 1422])//添加一个图片(背景图)
        ->addImageResource($image, $qrcode_xy, [250, 250])//添加一个图片资源(上方得到的二维码)
        //->addQrCode('https://me.csdn.net/xzw1315915745', [250, 250], Poster::POSITION_RIGHT_BOTTOM)//直接添加二维码方式，可以直接设置二维码在海报的位置，但无 logo
        ->addUser($head_portrait, $nickname, Poster::POSITION_TOP_LEFT_CORNER)//添加用户头像和昵称信息
        ->addText('A B C', 72, [80, 330], '#33ff99', $font_path)//添加文字，
        ->render();//浏览器输出图片，传入图片路径，即可直接输出到服务器 render($image_save_path);
```

方法介绍
----

[](#方法介绍)

#### 构造方法

[](#构造方法)

```
    /**
    * Poster constructor.
    * @param $width 海报宽度
    * @param $height 海报高度
    * @param array $background_image_color 16进制背景颜色 #cccccc
    */
    $poster = new Xuxuxuzw\Poster\Poster($width,$height,$background_image_color = '#cccccc');
```

#### 添加图片

[](#添加图片)

```
    /**
    * 添加图片
    * User : xuzhaowen
    * @param $img_path 图片路径
    * @param array $xy 坐标
    * @param array $size_wh 宽度高度
    * @return $this
    */
    public function addImage($img_path, $xy = [0, 0], $size_wh = [100, 100]){}
```

#### 添加图片资源

[](#添加图片资源)

```
	/**
     * 添加图片资源
     * User : xuzhaowen
     * @param $imageResource 图片资源
     * @param array $xy 坐标
     * @param array $size_wh 宽度高度
     * @return $this
     */
    public function addImageResource($imageResource, $xy = [0, 0], $size_wh = [100, 100]){}
```

#### 添加文字

[](#添加文字)

```
	/**
     * 添加文字
     * User : xuzhaowen
     * @param string $text 文字内容
     * @param int $size 字体大小，单位px
     * @param array $xy 坐标
     * @param array $color 16进制颜色 #000000
     * @param string $font_file 字体包路径
     * @param int $angle 透明度
     * @return $this
     */
    public function addText($text, $size = 14, $xy = [0, 0], $color = '#000000', $font_file, $angle = 0){}
```

#### 添加二维码

[](#添加二维码)

```
	/**
     * 添加二维码
     * User : xuzhaowen
     * @param $text 文字内容
     * @param array $size_wh 宽度高度
     * @param int $position 坐标方向（使用自带的7个坐标值）
     * @param array $xy 坐标 $position 无效时有效
     * @return $this
     */
    public function addQrCode($text, $size_wh = [100, 100], $position = 0, $xy = [0, 0]){}
```

#### 添加用户头像和用户昵称

[](#添加用户头像和用户昵称)

```
	/**
     * 添加用户头像和用户昵称
     * User : xuzhaowen
     * @param array $head_portrait
          [
            'width' => 120,//头像宽度
            'height' => 120,//头像高度
            'img_path' => './resource/avatar.png', //头像路径
            'is_circular'=>false, //是否圆形的
        ]
     * @param array $nickname
          [
            'user_name' => 'xzw', //用户昵称
            'font_path' => $font_path, //字体包路径
            'font_size' => 18, //昵称字体大小
     		'color' => '#3399ff' //16进制颜色 #000000
        ]
     * @param int $position 坐标方向（使用自带的7个坐标值）
     * @return $this
     */
    public function addUser($head_portrait, $nickname, $position = 0){}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Total

3

Last Release

2199d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83fe7befeb0aeeffa13eef8591663ced1ee04f53337b27e38cec6f30319720c9?d=identicon)[xuxuxuzw](/maintainers/xuxuxuzw)

---

Top Contributors

[![xuxuxuzw](https://avatars.githubusercontent.com/u/32591013?v=4)](https://github.com/xuxuxuzw "xuxuxuzw (5 commits)")

### Embed Badge

![Health badge](/badges/xuxuxuzw-poster/health.svg)

```
[![Health](https://phpackages.com/badges/xuxuxuzw-poster/health.svg)](https://phpackages.com/packages/xuxuxuzw-poster)
```

###  Alternatives

[hanson/vbot

高度自定义的微信机器人，能够实现群控制，自动回复，消息转发，防撤回，留言统计等功能

4.4k14.4k12](/packages/hanson-vbot)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
