PHPackages                             janmas/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. janmas/poster

ActiveLibrary

janmas/poster
=============

GD海报生成

00PHP

Since Sep 24Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (1)Used By (0)

### 合成海报

[](#合成海报)

#### Poster类解析

[](#poster类解析)

```
不传path则创建空白画布
传path则以path文件为画布

$poster = new Post(
    $path //图片路径
);

```

##### create

[](#create)

- 创建画布

```
$poster->create(
	$width=0,//画布宽
	$height=0//画布高
	);

```

##### setPicture

[](#setpicture)

- 添加图片

```
$poster->setPicture(
	$path,//图片路径
	$tar_w=0,//原图要载入的宽度 -1为跟随画布大小
	$tar_h=0,//原图要载入的高度 -1为跟随画布大小
	$dst_x=0,//设定需要载入的图片在新图中的x坐标
	$dst_y=0,//设定需要载入的图片在新图中的y坐标
	$src_w=-1,//原图要载入的宽度 -1为原图大小
	$src_h=-1,//原图要载入的高度-1为原图大小
	$src_x=0,//设定载入图片要载入的区域x坐标
	$src_y=0//设定载入图片要载入的区域y坐标
	);

```

参数名类型描述$pathstring图片路径$tar\_wint原图要载入的宽度$tar\_hint原图要载入的高度$dst\_xint设定需要载入的图片在新图中的x坐标$dst\_yint设定需要载入的图片在新图中的y坐标$src\_wint原图要载入的宽度 -1为原图大小$src\_hint原图要载入的高度-1为原图大小$src\_xint设定载入图片要载入的区域x坐标$src\_yint设定载入图片要载入的区域y坐标##### setTtf

[](#setttf)

- 设置字体

```
$poster->setTtf($path);

```

##### setText

[](#settext)

- 在添加文字前一定要先设置字体
- 添加文字

```
$post->setText(
	$string='',//字符串
	$areaWidth=100,//字符区域大小
	$fontSize=12,//字体大小
	$rowHeight=12,//行高
	$maxRow=2,//最多几行
	$angle=0,//
	$x=0,//x轴偏移
	$y=0,//y轴偏移
	$color=[]//数组 [0=>255,1=>255,2=>255] 0是红色通道 1是绿色通道 2是蓝色通道
    );

```

参数名类型描述$stringstring字符串$areaWidthint字符区域大小$fontSizeint字体大小$rowHeightint行高$maxRowint最多几行$angleint原图要载入的宽度 -1为原图大小$xintx轴偏移$yinty轴偏移colorarray数组 \[0=&gt;255,1=&gt;255,2=&gt;255\] 0是红色通道 1是绿色通道 2是蓝色通道##### output

[](#output)

- 输出资源到文件

```
$poster->output(
	$filename,//文件路径（包含文件名）
	$quality=5//图片质量
	);

```

##### stream

[](#stream)

- 输出资源到浏览器

```
$poster->stream(
	$ext='png' //图片后缀
	);

```

##### eg：

[](#eg)

```
  $poster = new Poster();
  $poster->create(614,870);//创建画布
  $poster->setBackgroundColor(0,0,0xFFFFFF);//设置画布背景颜色
  $poster->setPicture('./../goods.png',614,583,-1,-1);//添加图片
  $poster->setPicture('./../b.png',177,177,-1,-1,614-177-65,583+65/2);
  $poster->setTtf('./ttf/ziti.ttf');//设置字体
  $poster->setText('长按识别二维码',177,18,12,1,0,644-177-65-65/2,583+177+65,[0,0,0]);//添加文字（添加文字前必须要先设置字体）
  $poster->output('./test/a.png');//输出文件（现在仅能输出到文本暂不支持输出到浏览器）

```

##### 注：仅支持jpg、png、jpeg、gif后缀类型

[](#注仅支持jpgpngjpeggif后缀类型)

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a70221db6c5245dc1f661624434e5aac6ea5da7503fadca4abb539692db629c?d=identicon)[Janmas Cromwell](/maintainers/Janmas%20Cromwell)

---

Top Contributors

[![moyuuuuuuuuuuu](https://avatars.githubusercontent.com/u/58201307?v=4)](https://github.com/moyuuuuuuuuuuu "moyuuuuuuuuuuu (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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