PHP code example of evidenceekanem / tinify-laravel

1. Go to this page and download the library: Download evidenceekanem/tinify-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/ */

    

evidenceekanem / tinify-laravel example snippets


    evidenceekanem\LaravelTinify\LaravelTinifyServiceProvider::class,

    'Tinify' => evidenceekanem\LaravelTinify\Facades\Tinify::class

    AWS_ACCESS_KEY_ID=
    AWS_SECRET_ACCESS_KEY=
    AWS_DEFAULT_REGION=
    AWS_BUCKET=

	$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', $AWS_BUCKET_name, '/path/to/save/in/bucket');

	$s3_result = Tinify::bufferToS3($source_data, $AWS_BUCKET_name, '/path/to/save/in/bucket');

	$s3_result = Tinify::urlToS3($image_url, $AWS_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();