PHPackages                             zjutsxj/think-autocropimage - 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. zjutsxj/think-autocropimage

ActiveLibrary

zjutsxj/think-autocropimage
===========================

autoCropImage package for thinkphp5.1

1.2(6y ago)19Apache-2.0PHP

Since Mar 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/zjutsxj/autoCropImage)[ Packagist](https://packagist.org/packages/zjutsxj/think-autocropimage)[ RSS](/packages/zjutsxj-think-autocropimage/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

autoCropImage - 图片自动缩放程序
========================

[](#autocropimage---图片自动缩放程序)

基于 ThinkPHP5.1+ 的图片缩放程序
将图片自动缩放成指定大小，减少图片体积，从而加快下载速度，降低下载时间和成本。

安装
--

[](#安装)

> composer require zjutsxj/think-autocropimage

使用方法
----

[](#使用方法)

[http://localhost/images/pic.jpg\_50x100.jpg](http://localhost/images/pic.jpg_50x100.jpg)
[http://localhost/images/pic.jpg\_50x100m2.jpg](http://localhost/images/pic.jpg_50x100m2.jpg)
[http://localhost/images/pic.jpg\_50x100v2014.jpg](http://localhost/images/pic.jpg_50x100v2014.jpg)
[http://localhost/images/pic.jpg\_50x100m2v2014.jpg](http://localhost/images/pic.jpg_50x100m2v2014.jpg)

### 使用说明

[](#使用说明)

方式一：50x100 缩放成 50x100 大小
方式二：50x100m2 方式一并且使用mode 2
方式三：50x100v2014 方式一并且指定缓存版本2014
方式四：50x100m2v2014 方式一，使用mode 2并且指定缓存版本2014

### 缩放模式说明

[](#缩放模式说明)

mode 1 : 强制裁剪，生成图片严格按照需要，不足放大，超过裁剪，图片始终铺满。
mode 2 : 和1类似，但不足的时候 不放大 会产生补白，可以用png消除。
mode 3 : 只缩放，不裁剪，保留全部图片信息，会产生补白。
mode 4 : 只缩放，不裁剪，保留全部图片信息，此时的参数只是限制了生成的图片的最大宽高，不产生补白。
mode 5 : 生成的图比例严格按照需要的比例，宽和高不超过给定的参数。

环境要求
----

[](#环境要求)

ThinkPHP5.1+

配置文件
----

[](#配置文件)

```
直接在应用的 config 目录下面创建 thumb.php 文件
return [
    // %1$s 宽, %2$s 高, %3$s 模式, %4$s 目录, %5$s 文件名
    'thumb_dir' => '/uploads/thumb/%1$sx%2$s_mode%3$s/%4$s/%5$s',

    /* 默认缩放模式 */
    'default_mode' => 1,

    /* 默认版本 */
    'default_version' => 1,

    /* 默认图片目录
     * 设置后将可以：
     * 1. URL 减少使用路径 http://localhost/images/pic.jpg_50x100.jpg > http://localhost/pic.jpg_50x100.jpg
     * 2. URL 隐藏原大小图片路径
     */
    'images_dir' => '',

    /* header 缓存时长 */
    'cache_time' => '1 years',
];

```

简单用法
----

[](#简单用法)

在 .htaccess 文件中添加以下代码

```
# 自动生成缩略图
RewriteRule ^.*(?:gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG)(?:_)([0-9]+)x([0-9]+)(?:m([1-5]))?(?:v([A-Za-z0-9_]*))?(?:.)?(?:gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG)?$ thumb.html [L,QSA]

```

存放缩略图目录权限修改为可写入
使用浏览器访问
[http://localhost/images/pic.jpg、](http://localhost/images/pic.jpg%E3%80%81)
[http://localhost/images/pic.jpg\_50x100.jpg](http://localhost/images/pic.jpg_50x100.jpg)
当第二个地址看见缩略图即安装成功

参考资料
----

[](#参考资料)

该扩展是参考 autoCropImage 项目进行扩展的
autoCropImage 开源项目

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~0 days

Total

3

Last Release

2260d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/zjutsxj-think-autocropimage/health.svg)

```
[![Health](https://phpackages.com/badges/zjutsxj-think-autocropimage/health.svg)](https://phpackages.com/packages/zjutsxj-think-autocropimage)
```

###  Alternatives

[topthink/think

the new thinkphp framework

8.0k1.2M13](/packages/topthink-think)[topthink/think-queue

The ThinkPHP6 Queue Package

640675.0k75](/packages/topthink-think-queue)[topthink/think-swoole

Swoole extend for thinkphp

477174.4k19](/packages/topthink-think-swoole)[topthink/think-captcha

captcha package for thinkphp

132934.4k68](/packages/topthink-think-captcha)[topthink/think-worker

workerman extend for thinkphp

202227.2k9](/packages/topthink-think-worker)[topthink/think-migration

96460.8k121](/packages/topthink-think-migration)

PHPackages © 2026

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