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

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

niweisi/php-poster
==================

php gif poster,Eye Copy.Compress html.

v1.0.0(5y ago)058proprietaryPHPPHP &gt;=7.0

Since Dec 25Pushed 5y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

poster
======

[](#poster)

#### 介绍

[](#介绍)

PHP 图片合成、生成海报、图片添加水印、生成二维码，合成二维码

合成gif图片

压缩html文件

#### 安装教程

[](#安装教程)

1. composer require niweisi/php-poster
2. composer update niweisi/php-poster

#### 使用说明

[](#使用说明)

1. -
    - \[buildIm 创建画布\]
    - @Author lang
    - @DateTime 2020-08-14T20:52:41+0800
    - @param number $w \[ 画布宽 \]
    - @param number $h \[ 画布高 \]
    - @param array $rgba \[ 颜色rbga \]
    - @param boolean $alpha \[ 是否透明 \]
2. - \[buildImDst 创建指定图片为画布\]
    - @Author lang
    - @DateTime 2020-08-15T11:14:48+0800
    - @param \[src\] $src \[ 图像资源 \]
    - @param integer $w \[description\]
    - @param integer $h \[description\]
    - @param array $rgba \[description\]
    - @param boolean $alpha \[description\]
    - @return \[type\] \[description\]
3. - \[buildImage 合成图片\]
    - @Author lang
    - @DateTime 2020-08-14T20:52:41+0800
    - @param \[string\] $src \[ 路径，支持网络图片（带http或https） \]
    - @param number $dst\_x \[ 目标x轴 特殊值 center 居中 支持百分比20% 支持自定义 支持正负 \]
    - @param number $dst\_y \[ 目标y轴 特殊值 center 居中 支持百分比20% 支持自定义 支持正负 \]
    - @param number $src\_x \[ 图片x轴 \]
    - @param number $src\_y \[ 图片y轴 \]
    - @param number $src\_w \[ 图片自定义宽 \]
    - @param number $src\_h \[ 图片自定义高 \]
    - @param boolean $alpha \[ 是否透明 是 true \]
    - @param string $type \[ 图片变形类型 'normal' 正常形状 'circle' 圆形 \]
    - @return array \[ 返回相对路径,数组 \]
4. - \[buildQr description\] 合成二维码
    - @Author lang
    - @Date 2020-10-14T12:14:06+0800
    - @param \[type\] $text \[内容\]
    - @param integer $dst\_x \[目标位置x\] 特殊值 center 居中 支持百分比20% 支持自定义 支持正负
    - @param integer $dst\_y \[目标位置y\] 特殊值 center 居中 支持百分比20% 支持自定义 支持正负
    - @param integer $src\_x \[图片x轴\]
    - @param integer $src\_y \[图片y轴\]
    - @param integer $size \[大小\]
    - @param integer $margin \[百变大小\]
    - @return \[type\] \[description\]
5. - \[buildText 合成文字\]
    - @Author lang
    - @DateTime 2020-08-14T22:09:20+0800
    - @param \[type\] $content \[description\]
    - @param integer $dst\_x \[description\]
    - @param integer $dst\_y \[description\]
    - @param integer $font \[ 字体大小 \]
    - @param array $rgba \[ 颜色rbga \]
    - @param integer $max\_w \[ 最大换行宽度 \]
    - @param string $font\_family \[ 字体，可不填，有默认 (相对路径为项目根目录) \]
    - @return \[type\] \[description\]
6. - \[getPoster 获取合成后图片文件地址\]
    - @Author lang
    - @DateTime 2020-08-16T15:45:57+0800
    - @return \[array\] \[返回文件地址\]
7. - \[setPoster 处理图片，需要传原图片\]
    - @Author lang
    - @Date 2020-08-17T15:55:31+0800
8. - \[Qr 生成二维码\]
    - @Author lang
    - @Date 2020-10-14T10:59:28+0800
    - @param \[type\] $text \[二维码包含的内容，可以是链接、文字、json字符串等等\]
    - @param \[type\] $outfile \[默认为false，不生成文件，只将二维码图片返回输出；否则需要给出存放生成二维码图片的文件名及路径\]
    - @param \[type\] $level \[容错级别，默认为L\]
    - ```
         可传递的值分别是L(QR_ECLEVEL_L，7%)、M(QR_ECLEVEL_M，15%)、Q(QR_ECLEVEL_Q，25%)、H(QR_ECLEVEL_H，30%)。

        ```
    - ```
         这个参数控制二维码容错率，不同的参数表示二维码可被覆盖的区域百分比，也就是被覆盖的区域还能识别

        ```
    - @param \[type\] $size \[控制生成图片的大小，默认为4\]
    - @param \[type\] $margin \[控制生成二维码的空白区域大小\]
    - @param \[type\] $saveandprint \[保存二维码图片并显示出来，$outfile必须传递图片路径\]
    - @return \[type\] \[description\]

#### 静态调用

[](#静态调用)

```
require '../vendor/autoload.php';

use niweisi\Poster\PosterManager;
use niweisi\Poster\Exception\Exception;

$fileName = 'output/poster.jpg';
# 合成图片
try {
    $result = PosterManager::Poster($fileName) //生成海报，这里写保存路径和文件名，可以指定图片后缀。默认png
    ->buildIm(638, 826, [255, 255, 255, 127], false)
        ->buildImage('images/top_bg.png')
        ->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('https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg', 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, [153, 153, 153, 1])
        ->buildText('我欲乘风归去，又恐琼楼玉宇，高处不胜寒。', 'center', 535, 14, [153, 153, 153, 1])
        ->buildText('起舞弄清影，何似在人间。转朱阁，低绮户，照无眠。', 'center', 555, 14, [153, 153, 153, 1])
        ->buildText('不应有恨，何事长向别时圆？', 'center', 575, 14, [153, 153, 153, 1])
        ->buildText('人有悲欢离合，月有阴晴圆缺，此事古难全。', 'center', 595, 14, [153, 153, 153, 1])
        ->buildText('但愿人长久，千里共婵娟。', 'center', 615, 14, [153, 153, 153, 1])
        ->buildText('长按识别', 497, 720, 15, [153, 153, 153, 1])
        ->buildText('查看TA的更多作品', 413, 757, 15, [153, 153, 153, 1])
        ->buildQr('http://www.520yummy.com', 37,
            692,
            0, 0,
            100, 100, // 二维码大小
            4, 1
        )
        ->getPoster();
//    # 给图片添加水印
//    $result = PosterManager::Poster() //给指定图片添加水印，这里为空就好
//    ->buildImDst(__DIR__.'/test.jpeg')
//        ->buildImage('https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg','-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();
}

```

### 合成gif图片

[](#合成gif图片)

```
require '../vendor/autoload.php';

use niweisi\Poster\GifCreator\GifCreator;

// Create an array containing file paths, resource var (initialized with imagecreatefromXXX),
// image URLs or even binary code from image files.
// All sorted in order to appear.

$frames = array(
    "../images/newyear.jpg",
    "../images/newyear_count.png",
);

// Create an array containing the duration (in millisecond) of each frames (in order too)
$durations = array(150, 150);

// Initialize and create the GIF !
$gc = new GifCreator();
$gc->create(
    $frames,
    $durations,
    0 // 动画停止前的GIF循环次数(设置为0以获得无限循环)
);
$gifBinary = $gc->getGif();
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: image/gif');
header('Content-Disposition: filename="butterfly.gif"');
echo $gifBinary;
exit;

```

### 压缩html文件

[](#压缩html文件)

```
require '../vendor/autoload.php';

use niweisi\Poster\Compress\Compress;

$html = file_get_contents('./test.html');
$html = Compress::html($html); // 压缩html文件
echo $html;
exit;

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

2015d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[inpsyde/composer-assets-compiler

Composer plugin that installs and compile frontend dependencies for installed Composer packages based on configuration.

24296.8k1](/packages/inpsyde-composer-assets-compiler)[fruitstudios/searchit

Configure powerful custom filters for an enhanced search experience in the Craft CMS control panel.

2840.8k](/packages/fruitstudios-searchit)[frosh/platform-html-minify

This plugin delivers minified HTML and minified inline JavaScript to visitors.

1179.8k](/packages/frosh-platform-html-minify)[okeuday/erlang_php

Erlang External Term Format for PHP

101.4k](/packages/okeuday-erlang-php)

PHPackages © 2026

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