1. Go to this page and download the library: Download ngandu-dev/tinify library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ngandu-dev / tinify example snippets
use Ngandu\Tinify\Client;
$tinify = new Client('yourtinifytoken');
use Ngandu\Tinify\Client;
$tinify = new Client(
token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
proxy: 'http://user:[email protected]:8080'
);
use Ngandu\Tinify\Client;
$tinify = new Client(token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
$tinify->toFile(
source: $tinify->fromFile('/home/tinify/pictures/test.png'),
path: '/home/tinify/pictures/test-compressed.png'
);
use Ngandu\Tinify\Exception\FileException;
use Ngandu\Tinify\Exception\NetworkException;
try {
$tinify->toFile(
source: $tinify->fromFile('/path/to/input.png'),
path: '/path/to/output.png'
);
} catch (FileException $exception) {
// The input could not be read or the output could not be written.
} catch (NetworkException $exception) {
// The Tinify request failed. HTTP failures expose the status on $exception->status.
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.