PHP code example of martijnvdb / php-image-resize

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

    

martijnvdb / php-image-resize example snippets


composer 



use Martijnvdb\ImageResize\ImageResize;

$image = new ImageResize(__DIR__ . '/image-1.jpg');

$image = new ImageResize(__DIR__ . '/image-1.jpg');
$image->export(__DIR__ . '/resized/image-1.webp');

$image = new ImageResize(__DIR__ . '/image-1.jpg');
$image->setWidth(500);
$image->setHeight(500);
$image->export(__DIR__ . '/resized/image-1.webp');

$image = new ImageResize(__DIR__ . '/image-1.jpg');
$image->setWidth(500);
$image->setHeight(500);
$image->ignoreRatio();
$image->export(__DIR__ . '/resized/image-1.webp');

$image = new ImageResize(__DIR__ . '/image-1.jpg');
$image->setQuality(0.65);
$image->export(__DIR__ . '/resized/image-1.webp');

$image = ImageResize::get(__DIR__ . '/image-1.jpg')
    ->setWidth(500)
    ->setHeight(500)
    ->setQuality(.8)
    ->ignoreRatio()
    ->export(__DIR__ . '/resized/image-1.webp');