PHP code example of michaeld555 / filament-cropper

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

    

michaeld555 / filament-cropper example snippets


  Cropper::make('image')
      ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
          return (string)str("image_path/" . $file->hashName());
      })->enableDownload()
      ->enableOpen()
      ->enableImageRotation()
      ->enableImageFlipping()
      ->imageCropAspectRatio('16:9'),

Cropper::make('avatar')
        ->avatar()
        ->enableOpen()
        ->enableDownload()
        ->modalSize('xl'),

Cropper::make('avatar')
        ->avatar()
        ->enableOpen()
        ->enableDownload()
        ->modalSize('xl')
        ->modalHeading("Crop Background Image")

Cropper::make('image')
            ->modalSize('xl')
            ->modalHeading("Crop Background Image")
            ->enableImageRotation()
            ->rotationalStep(5)
            ->enableImageFlipping()
            ->enabledAspectRatios([
                '2:3', '9:16', '5:5'
            ])
            ->zoomable(true)
            ->enableZoomButtons()
            ->enableAspectRatioFreeMode()
            ->imageCropAspectRatio('4:9')
  
Cropper::make('avatar')
		->enableOpen()
		->enableDownload()
		->generateThumbnailImage(),  
  
Cropper::make('avatar')
		->enableOpen()
		->enableDownload()
		->generateThumbnailImage()
		->generateThumbnailImageUsing(function(TemporaryUploadedFile $file, string $filename, string $diskName, ?string $directory, string $visibility){
			...Your Code Here
		})->removeThumbnailImageUsing(function(TemporaryUploadedFile $file, string $filePath, string $diskName, ?string $directory, string $visibility){  
			...Your Code Here
		})