This is an image compression provider for the Tinify API. Can be used alone or wiht the charcoal-image-compression package.
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"
]);
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.
--TBD--