PHPackages                             vintage/yii2-tinify - 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. [API Development](/categories/api)
4. /
5. vintage/yii2-tinify

ActiveYii2-extension[API Development](/categories/api)

vintage/yii2-tinify
===================

Facade of Tinify API for Yii2 Framework

2.1.0(8y ago)28.5k—10%2BSD-3-ClausePHP

Since Aug 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Vintage-web-production/yii2-tinify)[ Packagist](https://packagist.org/packages/vintage/yii2-tinify)[ RSS](/packages/vintage-yii2-tinify/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

 [ ![](https://camo.githubusercontent.com/6d10e3f4a4d1a00739a9e98e2aee81808c04a17e216b16f649e9df463cffd5c5/68747470733a2f2f74696e79706e672e636f6d2f696d616765732f736f6369616c2f776562736974652e6a7067) ](https://tinypng.com/)

Tinify API
==========

[](#tinify-api)

Facade of Tinify API for Yii2 Framework. This extension allows you to resize and compress images without loss of quality. For more information you can [read official](https://tinypng.com/developers/reference/php) API documentation for PHP.

[![Build Status](https://camo.githubusercontent.com/620f624e2ff989315b5c11e76746605d934028d721dcaba917a61e7e9e77dfef/68747470733a2f2f7472617669732d63692e6f72672f56696e746167652d7765622d70726f64756374696f6e2f796969322d74696e6966792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Vintage-web-production/yii2-tinify)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2d4eb4cdc08b0adaa34aae88780b1226557b1ea83d831826445aed82b0ab9cc1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f56696e746167652d7765622d70726f64756374696f6e2f796969322d74696e6966792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Vintage-web-production/yii2-tinify/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/f9956ba7633a23eb02e2f65b049d410b2921cab58d8f57617a4160532cae6a94/68747470733a2f2f706f7365722e707567782e6f72672f76696e746167652f796969322d74696e6966792f646f776e6c6f616473)](https://packagist.org/packages/vintage/yii2-tinify)[![Latest Stable Version](https://camo.githubusercontent.com/b9a49651be42760a0cc6a89a0c1bc32043ccf5a2025928d04b3591edcc405ebd/68747470733a2f2f706f7365722e707567782e6f72672f76696e746167652f796969322d74696e6966792f762f737461626c65)](CHANGELOG.md)[![Latest Unstable Version](https://camo.githubusercontent.com/7b57faded8ba3597a130dcbb6e6ca9eac45e22969008cfc53bd2b4543ebe0ac9/68747470733a2f2f706f7365722e707567782e6f72672f76696e746167652f796969322d74696e6966792f762f756e737461626c65)](CHANGELOG.md)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require vintage/yii2-tinify

```

or add

```
"vintage/yii2-tinify": "~2.1"

```

to the `require` section of your `composer.json`.

Usage
-----

[](#usage)

### Component

[](#component)

1. Configure API token in app params with key `tinify-api-token` or in `UploadedFile` component
2. Use `\vintage\tinify\UploadedFile` instead of `\yii\web\UploadedFile`

If you need to save some metadata, for example `location`, you can configure `saveMetadata` option like follow

```
use vintage\tinify\UploadedFile;

$file = UploadedFile::getInstance($model, 'image');
$file->saveMetadata = UploadedFile::METADATA_LOCATION;
// or more items
$file->saveMetadata = [UploadedFile::METADATA_LOCATION, UploadedFile::METADATA_CREATION];
```

### Upload files to AWS S3 storage

[](#upload-files-to-aws-s3-storage)

1. Configure AWS S3 service in `config/params-local.php`

```
use vintage\tinify\UploadedFileS3;

return [
    // ...
    UploadedFileS3::PARAM_KEY_AWS_ACCESS_KEY_ID         => '',
    UploadedFileS3::PARAM_KEY_AWS_SECRET_ACCESS_KEY     => '',
    UploadedFileS3::PARAM_KEY_S3_REGION                 => '',
    UploadedFileS3::PARAM_KEY_S3_BUCKET                 => '',
];
```

2. Use `\vintage\tinify\UploadedFileS3` insead of `\vintage\tinify\UploadedFile`
3. Provide region and bucket name in methods calls

```
$file = UploadedFile::getInstance($model, 'image')->saveAs('image.jpg');
```

also you can override region and bucket

```
$file = UploadedFile::getInstance($model, 'image')
    ->setRegion('us-west-1')
    ->setPath('images-bucket/uploads') // path must be provided without slash in the end
    ->saveAs('image.jpg');
```

### Resizing

[](#resizing)

You can resize uploaded file

```
$file = \vintage\tinify\UploadedFile::getInstance($model, 'image');
$file->resize() // creates \vintage\tinify\components\TinifyResize object
    ->fit() // resize algorithm, also you can use scale() and cover()
    ->width(600) // set image width
    ->height(400) // set image height
    ->process(); // resize image
$file->saveAs('@webroot/uploads');
```

or resize existing image

```
(new \vintage\tinify\components\TinifyResize('@webroot/uploads/image.jpg'))
    ->scale()
    ->width(600)
    ->process();
```

### CLI

[](#cli)

1. Configure console controller in `console/config/main.php`

```
'controllerMap' => [
    // ...
    'tinify' => \vintage\tinify\cli\TinifyController::class,
],
```

2. Run in console `./yii tinify/`

    CommandDescription`$ ./yii tinify/test-connect [api-token]`Test connection to API`$ ./yii tinify/compress '/path/to/src.jpg' '/path/to/dest.jpg'`Compress image`$ ./yii tinify/compress-catalog '/path/to/catalog'`Compress all images in catalog`$ ./yii tinify/count`Display compression images count

Tests
-----

[](#tests)

You can run tests with composer command

```
$ composer test

```

or using following command

```
$ codecept build && codecept run

```

Licence
-------

[](#licence)

[![License](https://camo.githubusercontent.com/8a8b44e5c13c48859bfaf4291336d9ac300f55772d3ca6e53713137310e5b8bb/68747470733a2f2f706f7365722e707567782e6f72672f76696e746167652f796969322d74696e6966792f6c6963656e7365)](LICENSE)

This project is released under the terms of the BSD-3-Clause [license](LICENSE).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

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

Total

4

Last Release

2983d ago

Major Versions

1.0.0 → 2.0.02017-10-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/22162d77618ce0d31a3280f4645890120b52c41dac52432192bc0ea0119bd65f?d=identicon)[Vintage-web-production](/maintainers/Vintage-web-production)

---

Top Contributors

[![greeflas](https://avatars.githubusercontent.com/u/17636915?v=4)](https://github.com/greeflas "greeflas (36 commits)")

---

Tags

api-wrapperimage-compressionimage-optimizationresized-imagestinify-apiyii2yii2-extensionapiresizecompressimagesyii2componenttinypngtinyjpgtinify

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/vintage-yii2-tinify/health.svg)

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

###  Alternatives

[tinify/tinify

PHP client for the Tinify API. Tinify compresses your images intelligently. Read more at https://tinify.com.

2515.2M71](/packages/tinify-tinify)[tinify/magento2

Make your web shop faster by compressing your JPEG and PNG images. This plugin automatically optimizes your images by integrating with the popular image compression services TinyJPG and TinyPNG.

4345.8k](/packages/tinify-magento2)[shortpixel/shortpixel-php

ShortPixel PHP SDK. Read more at https://shortpixel.com/api-tools

37531.5k10](/packages/shortpixel-shortpixel-php)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1243.1k1](/packages/skeeks-yii2-google-api)[sadovojav/yii2-image-thumbnail

Yii2 image thumbnail component

2142.1k](/packages/sadovojav-yii2-image-thumbnail)[dotzero/yii2-amocrm

Расширение для Yii Framework 2 реализующее клиент для работы с API amoCRM

1639.7k](/packages/dotzero-yii2-amocrm)

PHPackages © 2026

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