PHP code example of alexantr / image-resize

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

    

alexantr / image-resize example snippets


use Alexantr\ImageResize\Image;

$src1 = Image::init('uploads/pic.jpg')->crop(200, 200);
$src2 = Image::init('uploads/pic.jpg')->silhouette()->quality(95)->fit(200, 200);
$src3 = Image::init('uploads/pic.jpg')->fitWidth(200);
$src4 = Image::init('uploads/pic.jpg')->fitHeight(200);
$src5 = Image::init('/site/uploads/pic.jpg')->bgColor('6af')->fill(200, 200);



$webroot = __DIR__;
$path = isset($_GET['path']) ? $_GET['path'] : '';

Alexantr\ImageResize\Creator::create($webroot, $path);

<img src="<?= (new Image('uploads/pic.jpg'))->crop(200, 200) 

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^resized/(.*)$ image.php?path=$1 [L]