PHPackages                             yasmuru/ys-tinify-laravel - 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. yasmuru/ys-tinify-laravel

ActiveLibrary[API Development](/categories/api)

yasmuru/ys-tinify-laravel
=========================

Tinify API support with laravel

v1.0.2(8y ago)4136.2k16[5 PRs](https://github.com/yasmuru/ys-tinify-laravel/pulls)MITPHPPHP &gt;=5.5.0CI passing

Since Nov 15Pushed 1w ago2 watchersCompare

[ Source](https://github.com/yasmuru/ys-tinify-laravel)[ Packagist](https://packagist.org/packages/yasmuru/ys-tinify-laravel)[ RSS](/packages/yasmuru-ys-tinify-laravel/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (2)Versions (4)Used By (0)

Laravel Tinify
==============

[](#laravel-tinify)

Modern Laravel package for TinyPNG/TinyJPG image compression API. Compress and optimize your images with ease.

[![Latest Version on Packagist](https://camo.githubusercontent.com/548c68c6fc1f797a2187e4f71d5927ab90dc4fe4d7fd2555d67c883727bce4cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7961736d7572752f79732d74696e6966792d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yasmuru/ys-tinify-laravel)[![Tests](https://camo.githubusercontent.com/7335fa5eded5bd29d88233b72e26e4a0d9b5fce6adf0ae31450dabfc7903f4b3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7961736d7572752f79732d74696e6966792d6c61726176656c2f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/yasmuru/ys-tinify-laravel/actions/workflows/tests.yml)[![Code Quality](https://camo.githubusercontent.com/5cfbd782d760ba2aa09eeb58fc0dfddb6d8fd27b489e53aeb3e655213e5ff405/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7961736d7572752f79732d74696e6966792d6c61726176656c2f6c696e742e796d6c3f6272616e63683d6d6173746572266c6162656c3d636f64652532307175616c697479267374796c653d666c61742d737175617265)](https://github.com/yasmuru/ys-tinify-laravel/actions/workflows/lint.yml)[![Total Downloads](https://camo.githubusercontent.com/e1df98ba971081813e1831496cfe6878d067e3c72cd3439a9d4d8883cd13f424/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7961736d7572752f79732d74696e6966792d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yasmuru/ys-tinify-laravel)

Requirements
------------

[](#requirements)

- PHP 8.2, 8.3, or 8.4
- Laravel 11.x, 12.x, or 13.x

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

[](#installation)

Install the package via Composer:

```
composer require yasmuru/ys-tinify-laravel
```

### Configuration

[](#configuration)

The package will automatically register itself (Laravel auto-discovery).

Publish the configuration file (optional):

```
php artisan vendor:publish --tag=tinify-config
```

Add your TinyPNG API key to your `.env` file:

```
TINIFY_APIKEY=your-api-key-here
```

You can get a free API key at [tinypng.com/developers](https://tinypng.com/developers).

### Optional: AWS S3 Configuration

[](#optional-aws-s3-configuration)

If you want to directly upload compressed images to AWS S3, add these environment variables:

```
S3_KEY=your-aws-access-key
S3_SECRET=your-aws-secret-key
S3_REGION=your-s3-region
```

The bucket name is passed as an argument to each upload call, not configured globally.

Usage
-----

[](#usage)

### Basic Image Compression

[](#basic-image-compression)

```
use yasmuru\LaravelTinify\Facades\Tinify;

// Compress from file
$result = Tinify::fromFile('/path/to/image.jpg');

// Compress from buffer/string
$result = Tinify::fromBuffer($imageData);

// Compress from URL
$result = Tinify::fromUrl('https://example.com/image.jpg');

// Save compressed image to file
$result->toFile('/path/to/compressed-image.jpg');

// Get compressed image as buffer
$compressedData = $result->toBuffer();
```

### Direct Upload to AWS S3

[](#direct-upload-to-aws-s3)

Upload compressed images directly to S3 without saving locally:

```
use yasmuru\LaravelTinify\Facades\Tinify;

// Compress file and upload to S3
$s3Result = Tinify::fileToS3(
    '/path/to/image.jpg',
    'my-bucket',
    '/images/compressed-image.jpg'
);

// Compress buffer and upload to S3
$s3Result = Tinify::bufferToS3(
    $imageData,
    'my-bucket',
    '/images/compressed-image.jpg'
);

// Compress URL and upload to S3
$s3Result = Tinify::urlToS3(
    'https://example.com/image.jpg',
    'my-bucket',
    '/images/compressed-image.jpg'
);

// Get S3 image details
$imageUrl = $s3Result->location();
$imageWidth = $s3Result->width();
$imageHeight = $s3Result->height();
```

### Advanced Features

[](#advanced-features)

```
use yasmuru\LaravelTinify\Facades\Tinify;

// Check compression count (free tier has 500 compressions/month).
// compressionCount() is an alias for getCompressionCount().
$count = Tinify::getCompressionCount();

// Set custom API key at runtime
Tinify::setKey('your-custom-api-key');

// Set app identifier
Tinify::setAppIdentifier('My Application');

// Validate the API key. Returns true only if the key is accepted by Tinify;
// returns false for an invalid key or any network/server failure.
$isValid = Tinify::validate();
```

### Resizing Images

[](#resizing-images)

You can combine compression with resizing using the Tinify SDK methods:

```
$result = Tinify::fromFile('/path/to/image.jpg')
    ->resize([
        'method' => 'fit',
        'width' => 150,
        'height' => 100
    ]);

$result->toFile('/path/to/resized-image.jpg');
```

Important Notes
---------------

[](#important-notes)

- **S3 Permissions**: Images uploaded directly to S3 are publicly readable by default. Configure your S3 bucket permissions according to your privacy requirements.
- **API Limits**: The free TinyPNG API tier allows 500 compressions per month. Monitor your usage with `getCompressionCount()`.
- **Supported Formats**: PNG, JPEG, and WebP formats are supported.

Testing
-------

[](#testing)

```
composer install
composer check   # runs PHPStan (level 8) + PHPUnit
# or individually:
composer analyse
composer test
```

CI runs the suite against PHP 8.2/8.3/8.4 × Laravel 11/12/13.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- [yasmuru](https://github.com/yasmuru)
- [All Contributors](../../contributors)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance64

Regular maintenance activity

Popularity39

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 91.7% 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 ~218 days

Total

3

Last Release

3075d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4990447?v=4)[Murugan D](/maintainers/yasmuru)[@yasmuru](https://github.com/yasmuru)

---

Top Contributors

[![yasmuru](https://avatars.githubusercontent.com/u/4990447?v=4)](https://github.com/yasmuru "yasmuru (11 commits)")[![muruganstr](https://avatars.githubusercontent.com/u/20831486?v=4)](https://github.com/muruganstr "muruganstr (1 commits)")

---

Tags

laraveltinify-apilaraveltinypngtinify

### Embed Badge

![Health badge](/badges/yasmuru-ys-tinify-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/yasmuru-ys-tinify-laravel/health.svg)](https://phpackages.com/packages/yasmuru-ys-tinify-laravel)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[riclep/laravel-storyblok

A Laravel wrapper around the Storyblok API to provide a familiar experience for Laravel devs

6277.0k5](/packages/riclep-laravel-storyblok)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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