Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Tinify Compression Provider

License Latest Stable Version Code Quality Coverage Status Build Status

This is an image compression provider for the Tinify API. Can be used alone or wiht the charcoal-image-compression package.

Configuration

The Tinify provider needs a Tinify API key. The configuration can be project wide or scoped to the provider while instantiating.

In project conifg, to use with ImageCompression module :

{
    "modules": {
        "charcoal/image-compression/image-compression": {
            "providers": [
                {
                    "type": "tinify",
                    "key": "9CnT59Tj3D22vzWBM5bf8krKWsstrN5e"
                }
            ]
        }
    }
}

When instantiating, passing the key in the provider constructor :

use Charcoal\ImageCompression\Provider\Tinify\TinifyProvider;

$provider = new TinifyProvider([
    'key' => "9CnT59Tj3D22vzWBM5bf8krKWsstrN5e"
]);

Usage

use Charcoal\ImageCompression\Provider\Tinify\TinifyProvider;

$provider = new TinifyProvider([
    'key' => "9CnT59Tj3D22vzWBM5bf8krKWsstrN5e"
]);

// get the total compressions count for the current month
$provider->compressionCount();

// compress a file
$provider->compress($source, $target);

Every API requests need an API key. Tinify supports a free tier which allows for 500 compressions per month.

Installation

--TBD--