PHPackages                             tegic/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. [Image &amp; Media](/categories/media)
4. /
5. tegic/poster

ActiveProject[Image &amp; Media](/categories/media)

tegic/poster
============

PHP生成海报

v2.0.1(4y ago)07MITPHPPHP &gt;=5.6.0

Since Oct 14Pushed 4y agoCompare

[ Source](https://github.com/teg1c/poster)[ Packagist](https://packagist.org/packages/tegic/poster)[ RSS](/packages/tegic-poster/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (10)Used By (0)

### **poster**

[](#poster)

#### 介绍

[](#介绍)

基于gd库、phpqrcode

PHP海报生成插件，极速生成方便快捷。

快速生成海报、生成签到日、生成二维码、合成二维码、图片添加水印

提示：

1.新增批量处理方法

2.新增字体加粗参数

3.新增字体间隔参数

#### authors

[](#authors)

lang

#### 安装或更新教程

[](#安装或更新教程)

1. composer require kkokk/poster
2. composer update kkokk/poster

#### 使用说明

[](#使用说明)

注意：没有特别说明，统一都是px。

文档地址：

演示效果

[![输入图片说明](https://camo.githubusercontent.com/3dbe9774fb5acbd4e0af866050abf00609a7953adb6399d7abc90b4eec486d25/68747470733a2f2f63646e2e6c6561726e6b752e636f6d2f75706c6f6164732f696d616765732f3230323131302f32302f35343033362f4b7674316356357967422e706e67216c61726765 "在这里输入图片标题")](https://camo.githubusercontent.com/3dbe9774fb5acbd4e0af866050abf00609a7953adb6399d7abc90b4eec486d25/68747470733a2f2f63646e2e6c6561726e6b752e636f6d2f75706c6f6164732f696d616765732f3230323131302f32302f35343033362f4b7674316356357967422e706e67216c61726765)

演示地址：暂无

​ 生成签到日历海报、邀请海报

##### **引用海报类**

[](#引用海报类)

```
use Kkokk\Poster\PosterManager;
use Kkokk\Poster\Exception\Exception;

$poster = PosterManager::Poster('poster/poster_user'); # 设置保存路径和文件名
```

##### **创建画布**

[](#创建画布)

```
$poster->buildIm($w,$h,$rgba,$alpha); # 创建画布
```

参数说明

变量类型必填注释wnumber是画布宽hnumber是画布高rgbaarray否颜色rbga,\[255,255,255,1\]alphaboolean否是否透明，是：true##### **创建指定图片为画布**

[](#创建指定图片为画布)

```
$poster->buildImDst($src,$w,$h,$rgba,$alpha); # 创建指定图片为画布
```

参数说明

变量类型必填注释srcsource是图像资源wnumber否画布宽，默认原图宽hnumber否画布高，默认原图高rgbaarray否颜色rbga，\[255,255,255,1\]alphaboolean否是否透明，默认false##### **合成图片**

[](#合成图片)

```
$poster->buildImage($src,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h,$alpha,$type); # 合成图片
```

参数说明

变量类型必填注释srcstring是路径，支持网络图片（带http或https）dst\_xnumber|string否目标x轴 特殊值 center 居中 支持百分比20% 支持自定义 支持正负dst\_ynumber|string否目标y轴 特殊值 center 居中 支持百分比20% 支持自定义 支持正负src\_xnumber否图片x轴，默认0src\_ynumber否图片y轴，默认0src\_wnumber否图片自定义宽，默认原宽src\_hnumber否图片自定义高，默认原高alphaboolean否是否透明，true：是typestring否图片变形类型，正常形状：'normal'，圆形：'circle' ，默认normal##### **批量合成图片**

[](#批量合成图片)

```
$images = [
    [
        'src'   => $src,
        'dst_x' => $dst_x,
        'dst_y' => $dst_y,
        'src_x' => $src_x,
        'src_y' => $src_y,
        'src_w' => $src_w,
        'src_h' => $src_h,
        'alpha' => $alpha,
        'type'  => $type
    ]
];
$poster->buildImageMany($images); # 批量合成图片
```

参数说明：与**合成图片**参数一致。

##### **合成二维码**

[](#合成二维码)

```
$poster->buildQr($text,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h,$size,$margin); # 合成二维码
```

参数说明

变量类型必填注释textstring是内容，例如：dst\_xnumber|string否画布位置x 特殊值 center 居中 支持百分比20% 支持自定义 支持正负dst\_ynumber|string否画布位置y 特殊值 center 居中 支持百分比20% 支持自定义 支持正负src\_xnumber否图片x轴，默认0src\_ynumber否图片y轴，默认0src\_wnumber否图片自定义宽，默认原宽src\_hnumber否图片自定义高，默认原高alphainteger否大小，默认4margininteger否白边大小，默认1##### **批量合成二维码**

[](#批量合成二维码)

```
$qrs = [
    [
        'text'   => $text,
        'dst_x'  => $dst_x,
        'dst_y'  => $dst_y,
        'src_x'  => $src_x,
        'src_y'  => $src_y,
        'src_w'  => $src_w,
        'src_h'  => $src_h,
        'size'   => $size,
        'margin' => $margin
    ]
];
$poster->buildQrMany($qrs); # 批量合成二维码
```

参数说明：与**合成二维码**参数一致。

##### 合成文字

[](#合成文字)

```
$poster->buildText($content,$dst_x,$dst_y,$font,$rgba,$max_w,$font_family,$weight,$space); # 合成文字
```

参数说明

变量类型必填注释contentstring是内容，例如：dst\_xnumber|string|array否画布位置x ；特殊值 center 居中；居中并向左偏移 \['center',-5\]， 居中并向右偏移 \['center',5\]dst\_ynumber否画布位置y，默认0fontnumber否字体大小，默认16rgbanumber否颜色rbga，\[255,255,255,1\]max\_wnumber否最大换行宽度，默认0不换行。达到换行宽度自动换行font\_familynumber否字体，可不填，有默认 (相对路径为项目根目录)weightinteger否字体粗细 默认字体大小spaceinteger否字体间距 默认无##### 批量合成文字

[](#批量合成文字)

```
$texts = [
    [
        'content'     => $content,
        'dst_x'       => $dst_x,
        'dst_y'       => $dst_y,
        'font'        => $font,
        'rgba'        => $rgba,
        'max_w'       => $max_w,
        'font_family' => $font_family,
        'weight'      => $weight,
        'space'       => $space
    ]
];
$poster->buildQrMany($texts); # 批量合成文字
```

参数说明：与**合成文字**参数一致。

##### 获取海报

[](#获取海报)

```
$poster->getPoster(); # 获取合成后图片文件地址
```

参数说明：无。

返回说明：返回数组，返回文件地址。

##### 处理海报、图片

[](#处理海报图片)

```
$poster->setPoster(); # 处理图片，需要传原图片
```

参数说明：无。

返回说明：处理原图片资源，无返回。

##### 输出图片流

[](#输出图片流)

```
$poster->stream(); # 输出图片流
```

参数说明：无。

返回说明：返回文件流，可输出到浏览器或img标签。

##### 生成二维码

[](#生成二维码)

```
$qr = PosterManager::Poster()->Qr('http://www.520yummy.com','poster/1.png'); # 生成二维码
```

参数说明

变量类型必填注释textstring是二维码包含的内容，可以是链接、文字、json字符串等等，例如：outfileboolean|string否默认为false，不生成文件，只将二维码图片返回输出；否则需要给出存放生成二维码图片的文件名及路径levelstring否容错级别，默认为L， 可传递的值分别是L(QR\_ECLEVEL\_L，7%)、M(QR\_ECLEVEL\_M，15%)、Q(QR\_ECLEVEL\_Q，25%)、H(QR\_ECLEVEL\_H，30%)。这个参数控制二维码容错率，不同的参数表示二维码可被覆盖的区域百分比，也就是被覆盖的区域还能识别sizeinteger否控制生成图片的大小，默认为4margininteger否控制生成二维码的空白区域大小，默认4saveandprintboolean否保存二维码图片并显示出来，outfile 必须传递图片路径，默认false返回说明：outfile 为空，输出二维码图片，不生成文件；否则返回图片路径。

#### 示例

[](#示例)

##### 静态调用

[](#静态调用)

```
use Kkokk\Poster\PosterManager;
use Kkokk\Poster\Exception\Exception;
# 合成图片
try {
    $addImage = "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg";
	$result = PosterManager::Poster('poster/poster_user') //生成海报，这里写保存路径和文件名，可以指定图片后缀。默认png
	->buildIm(638,826,[255,255,255,127],false)
	->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png')
	->buildImage('https://test.acyapi.51acy.com/wechat/poster/half_circle.png',254,321)
	->buildImage($addImage,253,326,0,0,131,131,false,'circle')
	->buildImage('https://test.acyapi.51acy.com/wechat/poster/fengexian.png',0,655)
	->buildText('苏 轼','center',477,16,[51, 51, 51,1])
	->buildText('明月几时有，把酒问青天。不知天上宫阙，今夕是何年。','center',515,14,[53, 53, 53, 1])
	->buildText('我欲乘风归去，又恐琼楼玉宇，高处不胜寒。','center',535,14,[53, 153, 153, 1])
	->buildText('起舞弄清影，何似在人间。转朱阁，低绮户，照无眠。','center',555,14,[53, 153, 153, 1])
	->buildText('不应有恨，何事长向别时圆？','center',575,14,[53, 153, 153, 1])
	->buildText('人有悲欢离合，月有阴晴圆缺，此事古难全。','center',595,14,[53, 153, 153, 1])
	->buildText('但愿人长久，千里共婵娟。','center',615,14,[53, 153, 153, 1])
	->buildText('长按识别',497,720,15,[53, 153, 153, 1])
	->buildText('查看TA的更多作品',413,757,15,[53, 153, 153, 1])
	->buildQr('http://www.520yummy.com',37,692,0,0,0,0,4,1)
	->getPoster();

	# 批量合成
	$buildImageManyArr = [
		[
        	'src' => 'https://test.acyapi.51acy.com/wechat/poster/top_bg.png'
        ],
        [
            'src' => 'https://test.acyapi.51acy.com/wechat/poster/half_circle.png',
            'dst_x' => 254,
            'dst_y' => 321
        ],
        [
            'src' => 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg',
            'dst_x' => 253,
            'dst_y' => 326,
            'src_x' => 0,
            'src_y' => 0,
            'src_w' => 131,
            'src_h' => 131,
            'alpha' => false,
            'type'  => 'circle'
        ],
        [
            'src'   => 'https://test.acyapi.51acy.com/wechat/poster/fengexian.png',
            'dst_x' => 0,
            'dst_y' => 655
        ]
	];
	$buildTextManyArr  = [
		[
            'content'=> '苏轼',
            'dst_x' => 'center',
            'dst_y' => 477,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '明月几时有，把酒问青天。不知天上宫阙，今夕是何年。',
            'dst_x' => 'center',
            'dst_y' => 515,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '我欲乘风归去，又恐琼楼玉宇，高处不胜寒。',
            'dst_x' => 'center',
            'dst_y' => 535,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '起舞弄清影，何似在人间。转朱阁，低绮户，照无眠。',
            'dst_x' => 'center',
            'dst_y' => 555,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '不应有恨，何事长向别时圆？',
            'dst_x' => 'center',
            'dst_y' => 575,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '人有悲欢离合，月有阴晴圆缺，此事古难全。',
            'dst_x' => 'center',
            'dst_y' => 595,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '但愿人长久，千里共婵娟。',
            'dst_x' => 'center',
            'dst_y' => 615,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '长按识别',
            'dst_x' => 'center',
            'dst_y' => 720,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ],
        [
            'content'=> '查看TA的更多作品',
            'dst_x' => 'center',
            'dst_y' => 757,
            'font' => 16,
            'rgba' => [51, 51, 51, 1],
            'max_w'=> 0,
            'font_family' => '',
            'weight' => 1,
            'space'=>20
        ]
	];
	$buildQrManyArr    = [
		[
			'text'=>'http://www.520yummy.com',
            'dst_x'=>37,
            'dst_y'=>692,
            'src_x'=>0,
            'src_y'=>0,
            'src_w'=>0,
            'src_h'=>0,
            'size'=>4,
            'margin'=>1
		],
		[
			'text'=>'http://www.520yummy.com',
            'dst_x'=>74,
            'dst_y'=>692,
            'src_x'=>0,
            'src_y'=>0,
            'src_w'=>0,
            'src_h'=>0,
            'size'=>4,
            'margin'=>1
		]
	];

	$result = PosterManager::Poster('poster/poster_user')
	->buildIm(638,826,[255,255,255,127],false)
	->buildImageMany($buildImageManyArr)
	->buildTextMany($buildImageManyArr)
	->buildQrMany($buildQrManyArr)
	->getPoster();

    # 给图片添加水印
    $setImage = "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg";
	$result = PosterManager::Poster() //给指定图片添加水印，这里为空就好
	->buildImDst(__DIR__.'/test.jpeg')
	->buildImage($setImage,'-20%','-20%',0,0,0,0,false)
	->setPoster();

	# 生成二维码
	$result = PosterManager::Poster()->Qr('http://www.baidu.com','poster/1.png');
} catch (Exception $e){
	echo $e->getMessage();
}
```

##### 实例化调用

[](#实例化调用)

```
use Kkokk\Poster\PosterManager;
use Kkokk\Poster\Exception\Exception;
# 合成图片
try {
    $addImage = "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg";
	$PosterManager = new PosterManager('poster/poster_user'); //生成海报，这里写保存路径和文件名，可以指定图片后缀。默认png
	$result = $PosterManager->buildIm(638,826,255,255,255,1]27,false)
	->buildIm(638,826,[255,255,255,127],false)
	->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png')
	->buildImage('https://test.acyapi.51acy.com/wechat/poster/half_circle.png',254,321)
	->buildImage($addImage,253,326,0,0,131,131,false,'circle')
	->buildImage('https://test.acyapi.51acy.com/wechat/poster/fengexian.png',0,655)
	->buildText('苏 轼','center',477,16,[51, 51, 51,1])
	->buildText('明月几时有，把酒问青天。不知天上宫阙，今夕是何年。','center',515,14,[53, 53, 53, 1])
	->buildText('我欲乘风归去，又恐琼楼玉宇，高处不胜寒。','center',535,14,[53, 153, 153, 1])
	->buildText('起舞弄清影，何似在人间。转朱阁，低绮户，照无眠。','center',555,14,[53, 153, 153, 1])
	->buildText('不应有恨，何事长向别时圆？','center',575,14,[53, 153, 153, 1])
	->buildText('人有悲欢离合，月有阴晴圆缺，此事古难全。','center',595,14,[53, 153, 153, 1])
	->buildText('但愿人长久，千里共婵娟。','center',615,14,[53, 153, 153, 1])
	->buildText('长按识别',497,720,15,[53, 153, 153, 1])
	->buildText('查看TA的更多作品',413,757,15,[53, 153, 153, 1])
	->buildQr('http://www.520yummy.com',37,692,0,0,0,0,4,1)
	->getPoster();

	# 给图片添加水印
    $setImage = 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg';
	$PosterManager = new PosterManager(); //给指定图片添加水印，这里为空就好
	$result = $PosterManager->buildImDst(__DIR__.'/test.jpeg')
	->buildImage($setImage,'center','-20%',0,0,0,0,true)
	->setPoster();

	# 生成二维码
	$result = $PosterManager->Qr('http://www.baidu.com','poster/1.png');

} catch (Exception $e){
	echo $e->getMessage();
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.6% 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 ~51 days

Recently: every ~12 days

Total

9

Last Release

1629d ago

Major Versions

v1.0.0 → v2.0.02021-12-01

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27796058?v=4)[tegic](/maintainers/teg1c)[@teg1c](https://github.com/teg1c)

---

Top Contributors

[![kkokk](https://avatars.githubusercontent.com/u/18664878?v=4)](https://github.com/kkokk "kkokk (35 commits)")[![teg1c](https://avatars.githubusercontent.com/u/27796058?v=4)](https://github.com/teg1c "teg1c (2 commits)")

### Embed Badge

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

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

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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