1. Go to this page and download the library: Download mx-rt/tinypng-laravel 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/ */
$result = Tinify::fromFile('\path\to\file');
$result = Tinify::fromBuffer($source_data);
$result = Tinify::fromUrl($image_url);
/** To save as File **/
$result->toFile('\path\to\save');
/** To get image as data **/
$data = $result->toBuffer();
$s3_result = Tinify::fileToS3('\path\to\file', $s3_bucket_name, '/path/to/save/in/bucket');
$s3_result = Tinify::bufferToS3($source_data, $s3_bucket_name, '/path/to/save/in/bucket');
$s3_result = Tinify::urlToS3($image_url, $s3_bucket_name, '/path/to/save/in/bucket');
/** To get the url of saved image **/
$s3_image_url = $s3_result->location();
$s3_image_width = $s3_result->width();
$s3_image_hight = $s3_result->height();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.