PHPackages                             aileshe/thumb - 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. aileshe/thumb

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

aileshe/thumb
=============

Thumbnail generator

v1.1.1(8y ago)7135818[1 issues](https://github.com/aileshe/Thumb/issues)MITPHPPHP &gt;=5.3

Since Apr 10Pushed 8y agoCompare

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

READMEChangelogDependenciesVersions (4)Used By (0)

Thumb是什么?
=========

[](#thumb是什么)

Thumb是一个图片等比例缩放的PHP依赖，使用Thumb可以轻松生成不变形的缩略图。

安装
==

[](#安装)

通过composer，这是推荐的方式，可以使用composer.json 声明依赖，或者直接运行下面的命令。

```
composer require aileshe/thumb:*

```

放入composer.json文件中

```
    "require": {
        "aileshe/thumb": "*"
    }

```

然后运行

```
composer update

```

基本用法
====

[](#基本用法)

1. 生成一张缩略图

```
    $src = './public/upload/img_12.jpg'; // 原图路径
    $output = './public/upload/img_12_thumb.jpg'; // 输出保存文件名
    $width = 300; // 预生成缩略图的宽
    $height = 200; // 预生成缩略图的高
    \Thumb\Thumb::out($src,$output,$width,$height);

```

2. 生成缩略图直接输出图象到浏览器

```
    $src = './public/upload/img_12.jpg'; // 原图路径
    $width = 300; // 预生成缩略图的宽
    $height = 200; // 预生成缩略图的高
    \Thumb\Thumb::show($src,$width,$height);

```

3. 生成缩略图直接输出图象到浏览器并保存缩略图

```
    $src = './public/upload/img_12.jpg'; // 原图路径
    $output = './public/upload/img_12_thumb.jpg'; // 输出保存文件名
    $width = 300; // 预生成缩略图的宽
    $height = 200; // 预生成缩略图的高
    \Thumb\Thumb::showOut($src,$output,$width,$height);

```

高级用法 - 自定义缩略剪裁
==============

[](#高级用法---自定义缩略剪裁)

如一张纵向图片在固定宽高等比例缩放后得到的缩略图必须要剪裁部分，所以要么居中剪裁，要么顶部、底部剪裁再去掉多余部分。

```
缩略剪裁方式: middle、top、bottom (默认: 居中)
 ________________    ________________    ________________
 |                |  |                |  |                |
 |                |  |      top       |  |                |
 |________________|  |                |  |                |
 |                |  |________________|  |                |
 |     middle     |  |                |  |                |
 |                |  |                |  |________________|
 |----------------|  |                |  |                |
 |                |  |                |  |      bottom    |
 |                |  |                |  |                |
 |________________|  |________________|  |________________|

\Thumb\Thumb::out([原图路径],[缩图文件名],[缩略图宽],[缩略图高],[middle|top|bottom]);
\Thumb\Thumb::show([原图路径],[缩略图宽],[缩略图高],[middle|top|bottom]);
\Thumb\Thumb::showOut([原图路径],[缩图文件名],[缩略图宽],[缩略图高],[middle|top|bottom]);

```

联系
==

[](#联系)

Author: Dejan
QQ : 673008865

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

3

Last Release

2960d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/988c14fbb3c61d3bdbbb1dc723236b6bc062178c3f34f923bddc7a049ec42064?d=identicon)[aileshe](/maintainers/aileshe)

---

Top Contributors

[![aileshe](https://avatars.githubusercontent.com/u/28887594?v=4)](https://github.com/aileshe "aileshe (16 commits)")

---

Tags

phpphp5php7thumbs

### Embed Badge

![Health badge](/badges/aileshe-thumb/health.svg)

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

###  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)
