1. Go to this page and download the library: Download eventviva/php-image-resize 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/ */
eventviva / php-image-resize example snippets
$image = new \Gumlet\ImageResize();
use \Gumlet\ImageResize;
$image = new ImageResize();
$image = new ImageResize('image.jpg');
$image->scale(50);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->resizeToHeight(500);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->resizeToWidth(300);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->resizeToLongSide(500);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->resizeToShortSide(300);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->resizeToBestFit(500, 300);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->resize(500, 300, $allow_enlarge = True);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->resize(800, 600);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->crop(200, 200);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->crop(200, 200);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->crop(200, 200, true, ImageResize::CROPCENTER);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->crop(200, 200, true, ImageResize::CROPTOP);
$image->save('image2.jpg');
$image = new ImageResize('image.jpg');
$image->crop(200, 200, true, ImageResize::CROPBOTTOM);
$image->save('image2.jpg');
try{
$image = new ImageResize(null);
echo "This line will not be printed";
} catch (ImageResizeException $e) {
echo "Something went wrong" . $e->getMessage();
}