PHP code example of tihiy-production / php-image-compressor
1. Go to this page and download the library: Download tihiy-production/php-image-compressor 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/ */
tihiy-production / php-image-compressor example snippets
$source = tihiy\Compressor\ImageCompressor::sourceFile('uncompressed.jpg');
$source->toFile('compressed.jpg');
$sourceData = file_get_contents('uncompressed.jpg');
$resultData = tihiy\Compressor\ImageCompressor::sourceContent($sourceData)->toContent();
$source = tihiy\Compressor\ImageCompressor::sourceUrl('https://example.com/uncompressed.jpg');
$source->toFile('compressed.jpg');
bash
composer