PHPackages                             zodream/image - 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. zodream/image

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

zodream/image
=============

image, captcha

5.4(1y ago)1617221MITPHPPHP &gt;=8.2

Since Jan 4Pushed 1w ago2 watchersCompare

[ Source](https://github.com/zodream/image)[ Packagist](https://packagist.org/packages/zodream/image)[ Docs](https://github.com/zodream/image)[ RSS](/packages/zodream-image/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (8)Dependencies (2)Versions (10)Used By (1)

image
=====

[](#image)

使用 gd 对图片处理的封装，包含 验证码、水印、缩略图、二维码、图片拖拽验证

当前状态：一直开发中
----------

[](#当前状态一直开发中)

简单使用教程
------

[](#简单使用教程)

[验证码](#captcha)

[滑动验证码](#slider)

[文字点击验证](#hint)

[二维码](#qr)

[水印](#water)

[缩略图](#thumb)

[图片比较（简单版）](#compare)

[内容生成图片](#draw)

### 使用 iconfont 等类似字体图标

[](#使用-iconfont-等类似字体图标)

```
$image = new Image();
$res = $image->instance();
$res->create(ImageManager::createSize(200, 200));
$res->fill('#fff');
$res->text("\u{e709}", ImageManager::createFont(app_path('data/fonts/iconfont.ttf')), ImageManager::createPoint(100, 100));
$image->show();
```

\*\* 请注意：`\u{e709}` 表示一个字符，且字符串必须用双引号 \*\*

### ico 生成

[](#ico-生成)

```
use Zodream\Image\Ico;

$image = new Ico('1.png');
$image->saveAsSize('1.ico', $image->getSizes());
```

### 验证码

[](#验证码)

```
use Zodream\Image\Captcha;

$captcha = new Captcha();
$captcha->setConfigs([
    'width' => 200,
    'fontSize' => 20,
    'fontFamily' => 'Ubuntu_regular.ttf'
]);
$source = $captcha->generate();

$captcha->verify($_POST['captcha'], $source);
```

默认配置

```
[
    'characters' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', //随机因子
    'length' => 4,    //验证码长度
    'fontSize' => 0,   //指定字体大小
    'fontColor' => '',   //指定字体颜色, 可以是数组
    'fontFamily' => null,  //指定的字体
    'width' => 100,        // 图片宽
    'height' => 30,       // 图片高
    'angle' => 0,         //角度
    'sensitive' => true,   // 大小写敏感
    'mode' => 0           // 验证码模式： 0 文字 1 公式
]
```

### 二维码

[](#二维码)

```
use Zodream\Image\QrCode;

$qr = new QrCode();
$image = $qr->encode('123123');
$image->save();
```

### 水印

[](#水印)

文字水印

```
$image = new WaterMark();
$image->instance()->loadResource('1.jpg');
$image->addTextByDirection('water');
```

自定义水印

```
$image = new WaterMark();
$image->instance()->loadResource($file);
$font = new Font((string)app_path(config('disk.font')), 12, '#fff');
$textBox = $image->instance()->fontSize($text, $font);
// 根据文字的尺寸获取水印的位置
list($x, $y) = $image->getPointByDirection(WaterMark::RightTop, $textBox->getWidth(), $textBox->getHeight(), 20);
// 给文字添加阴影
$image->addText($text, $x + 2, $y + 2, $font->getSize(), '#777', $font->getFile());
$image->addText($text, $x, $y, $font->getSize(), $font->getColor(), $font->getFile());
```

### 滑动验证码

[](#滑动验证码)

```
use Zodream\Image\SlideCaptcha;

$captcha = new SlideCaptcha();
$captcha->setConfigs([
    'width' => 300,
    'height' => 130,
]);
$captcha->instance()->open('bg.jpg');
$captcha->setShape('shape.jpg'); // 根据图片抠图
$source = $captcha->generate();

$captcha->verify($_POST['captcha'], $source);

$imgData = $captcha->toArray();
$html = '';
foreach ($imgData['imageItems'] as $point) {
    $html .= sprintf('', $point['x'], $point['y']);
}

$html = setConfigs([
    'width' => 300,
    'height' => 130,
    'fontSize' => 20,
    'fontFamily' => 'Yahei.ttf',
    'words' => $items,
    'count' => 3,
]);
$captcha->instance()->open('images/banner.jpg');
$source = $captcha->generate();

$captcha->verify($_POST['captcha'], $source);

$imgData = $captcha->toArray();
```

内容生成图片
------

[](#内容生成图片)

```
$str =  10,
    'background' => 'white',
    'width' => 470
])->append(
    ImgNode::create($img, [
        'width' => '100%',
        'height' => '100%'
    ]),
    TextNode::create('sbfajahaa', [
        'size' => 20,
        'letterSpace' => 20,
        'padding' => [
            10,
            0,
        ],
        'bold' => true,
        'font' => $font
    ]),
    TextNode::create('1234avccg', [
        'size' => 12,
        'font' => $font,
        'letterSpace' => 4,
        'lineSpace' => 4,
        'color' => '#ccc'
    ]),
    ImgNode::create($img, [
        'width' => '100',
        'height' => '100',
        'center' => true
    ]),
    TextNode::create('sbfajahaa', [
        'size' => 12,
        'color' => '#ccc',
        'letterSpace' => 4,
        'lineSpace' => 4,
        'wrap' => false,
        'font' => $font,
        'center' => true
    ]),
    BorderNode::create([
        'size' => 1,
        'fixed' => true,
        'margin' => 10
    ]),
    LineNode::create(10, 10, 10, 100, [
        'size' => 1,
        'fixed' => true,
        'color' => 'black'
    ]),
    RectNode::create([
        'points' => [
            [0, 0],
            [200, 0],
            [0, 200],
        ],
        'color' => 'black'
    ])
);
$box->beginDraw()->show();
```

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance76

Regular maintenance activity

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 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 ~331 days

Recently: every ~401 days

Total

9

Last Release

408d ago

Major Versions

v0.1 → v1.12018-01-05

1.2 → 4.02020-11-10

4.0 → 5.02021-02-24

PHP version history (5 changes)v1.0PHP &gt;=5.6.0

4.0PHP &gt;=7.0.0

5.0PHP &gt;=8.0

5.2PHP &gt;=8.1

5.3PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c11802f0024be431f68f581cdb4880e31a996e00d60f3cef00645c39d9da187a?d=identicon)[zx648383079](/maintainers/zx648383079)

---

Top Contributors

[![zx648383079](https://avatars.githubusercontent.com/u/9996852?v=4)](https://github.com/zx648383079 "zx648383079 (52 commits)")

---

Tags

zodreamimage gd

### Embed Badge

![Health badge](/badges/zodream-image/health.svg)

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

###  Alternatives

[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[imagekit/imagekit

PHP library for Imagekit

47795.6k9](/packages/imagekit-imagekit)[contao/image

Contao image library

131.7M9](/packages/contao-image)[intervention/image-driver-vips

libvips driver for Intervention Image

4495.5k6](/packages/intervention-image-driver-vips)

PHPackages © 2026

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