PHPackages                             moxuandi/yii2-tinypng - 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. moxuandi/yii2-tinypng

ActiveYii2-extension[Image &amp; Media](/categories/media)

moxuandi/yii2-tinypng
=====================

yii2-tinypng-Description

2231PHP

Since Mar 9Pushed 6y ago1 watchersCompare

[ Source](https://github.com/moxuandi/yii2-tinypng)[ Packagist](https://packagist.org/packages/moxuandi/yii2-tinypng)[ RSS](/packages/moxuandi-yii2-tinypng/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Tinify API client for PHP Framework Yii2
========================================

[](#tinify-api-client-for-php-framework-yii2)

Tinify API 的PHP客户端, 用于 TinyPNG 和 TinyJPG. Tinify 智能压缩你的图像. [阅读更多内容请看官网](https://tinypng.com).

安装:
---

[](#安装)

使用 [composer](http://getcomposer.org/download/) 下载:

```
# 2.2.x(yii >= 2.0.24):
composer require moxuandi/yii2-tinypng:"~2.2.0"

# 开发版:
composer require moxuandi/yii2-tinypng:"dev-master"

```

使用方法:
-----

[](#使用方法)

#### 1. 在`params`中添加 api key:

[](#1-在params中添加-api-key)

```
'tinyPngApiKeys' => [
    'vMClPPpGgT1WQ5nX7kmdrV5nWW7r6q9V',
    'Qg24qhk1xcxGsHvkfWZn4mMNkq64QqX8',
    'vk07xRY61h3LThY4BXyYLpHmHdvCvnvZ',
    'Y2bLBFbGwJ5w1JvPCj7BY68Jt0GzXTvz',
    '687t8JHGJBTq5rYC7tJ34jxxs5swWxCt',
    // ……
],
```

#### 2. 调用方法:

[](#2-调用方法)

```
$tiny = new TinyImage();
$resize = [
    'method' => 'thumb',
    'width' => 150,
    'height' => 100,
];

// 压缩单个文件:
$tiny->compressImage('example.png', 'thumb.png');

// 压缩多个文件:
$images = [
    'example1.png' => 'thumb1.png',
    'example2.png' => 'thumb2.png',
    'example3.png' => 'thumb3.png',
    // ……
];
$tiny->compressImages($images);

# 压缩整个目录(相对目录或绝对目录):
$source = Yii::getAlias('@webroot/uploads/image');
$target = Yii::getAlias('@webroot/upload/image');
$tiny->compressFile($source, $target, [], $resize);
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

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://avatars.githubusercontent.com/u/22020977?v=4)[moxuandi](/maintainers/moxuandi)[@moxuandi](https://github.com/moxuandi)

---

Top Contributors

[![moxuandi](https://avatars.githubusercontent.com/u/22020977?v=4)](https://github.com/moxuandi "moxuandi (12 commits)")

### Embed Badge

![Health badge](/badges/moxuandi-yii2-tinypng/health.svg)

```
[![Health](https://phpackages.com/badges/moxuandi-yii2-tinypng/health.svg)](https://phpackages.com/packages/moxuandi-yii2-tinypng)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[imagekit/imagekit

PHP library for Imagekit

46877.3k10](/packages/imagekit-imagekit)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

12644.1k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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