PHP code example of root4root / imgresize
1. Go to this page and download the library: Download root4root/imgresize 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/ */
root4root / imgresize example snippets
use Root4root\ImgResize\ImgResize;
$image = new ImgResize('pathToImage.jpg');
$image->resampleToHeight(500)
->sharpen()
->save('pathToSave.gif');
$watermark = new ImgResize('pathToWatermark.png');
$image->addImage(new ImgResize('anotherImage.png'))
->joinVertical()
->watermark($watermark)
->save('pathToSave.jpg');
$image->watermark($watermark)->save('pathToSave2.jpg');
$imageWithWatermark = (new ImgResize('pathToImage.jpg'))->watermark(new ImgResize('pathToWater.png'));
$imageWithWatermark->resampleToRectangle(500,500)->save('path.jpg'); //Fits image to rectangle by height or width - which is bigger.
$imageWithWatermark->resampleToWidth(1000)->sharpen()->save('path.png'); //Still one resample - best quality