PHP code example of movescode / cropper

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

    

movescode / cropper example snippets


use MovesCode\Cropper\Cropper;

$cropper = new Cropper(
    cachePath: 'storage/images/cache',
    quality: 75,
    compressor: 5
);

$proportional = $cropper->make('storage/images/photo.jpg', 500);
$cropped = $cropper->make('storage/images/photo.jpg', 500, 300);

$cropper = new Cropper('storage/images/cache', webP: true);
$thumb = $cropper->make('storage/images/photo.png', 800, 450);

$webp = $cropper->toWebP('storage/images/photo.png', unlinkImage: false);

$cropper->flush('storage/images/photo.jpg'); // somente essa origem
$cropper->flush();                           // todo o cache configurado