PHPackages                             devscast/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. devscast/tinify

ActiveLibrary[API Development](/categories/api)

devscast/tinify
===============

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

2.2.0(4mo ago)114951MITPHPPHP &gt;=8.4CI passing

Since Oct 30Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/devscast/tinify-php)[ Packagist](https://packagist.org/packages/devscast/tinify)[ RSS](/packages/devscast-tinify/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

Tinify PHP
==========

[](#tinify-php)

[![Latest Stable Version](https://camo.githubusercontent.com/12f86c55a39ed94b2e23c3d625fbf1d4e35fb095e1f50c2fdded8a98b44d686a/687474703a2f2f706f7365722e707567782e6f72672f64657673636173742f74696e6966792f76)](https://packagist.org/packages/devscast/tinify)[![Total Downloads](https://camo.githubusercontent.com/8835f11ec06555499a785aedc287f77a795bfc7ebcbd52b17fc5acc3b7b268ab/687474703a2f2f706f7365722e707567782e6f72672f64657673636173742f74696e6966792f646f776e6c6f616473)](https://packagist.org/packages/devscast/tinify)[![Latest Unstable Version](https://camo.githubusercontent.com/07571278f75b4aad6569c05f34268270b40fa20b7a21d21ac570242c6eda49d1/687474703a2f2f706f7365722e707567782e6f72672f64657673636173742f74696e6966792f762f756e737461626c65)](https://packagist.org/packages/devscast/tinify)[![License](https://camo.githubusercontent.com/597ae6bbc5e497569fefa115a5915074b12c66eb2a8431a6d0aff11173cb405f/687474703a2f2f706f7365722e707567782e6f72672f64657673636173742f74696e6966792f6c6963656e7365)](https://packagist.org/packages/devscast/tinify)[![PHP Version Require](https://camo.githubusercontent.com/10da5701b5164c83b0d3a4d95b2a89ad4d870ea302fdb45d2072870fe8f88646/687474703a2f2f706f7365722e707567782e6f72672f64657673636173742f74696e6966792f726571756972652f706870)](https://packagist.org/packages/devscast/tinify)

The Tinify API allows you to compress and optimize WebP, JPEG and PNG images. It is designed as a REST service. The client libraries in various languages make it very easy to interact with the Tinify API.

installation
------------

[](#installation)

You can use the PHP client by installing the Composer package and adding it to your application’s dependencies:

```
composer require devscast/tinify
```

Authentication
--------------

[](#authentication)

To use the API you must provide your API key. You can [get an API key](https://tinypng.com/developers) by registering with your name and email address. Always keep your API key secret!

```
use Devscast\Tinify\Client;

$tinify = new Client('yourtinifytoken');
```

All requests will be made over an encrypted [HTTPS](https://en.wikipedia.org/wiki/HTTPS) connection.

You can instruct the API client to make all requests over an HTTP proxy. Set the URL of your proxy server, which can optionally include credentials.

```
use Devscast\Tinify\Client;

$tinify = new Client(
    token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    proxy: 'http://user:pass@192.168.0.1:8080'
);
```

Compressing Images
------------------

[](#compressing-images)

You can upload any WebP, JPEG or PNG image to the Tinify API to compress it. We will automatically detect the type of image and optimise with the TinyPNG or TinyJPG engine accordingly. Compression will start as soon as you upload a file or provide the URL to the image. You can choose a local file as the source and write it to another file.

```
