1. Go to this page and download the library: Download riseuplabs/image-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/ */
// use your driver in (.env) file
FILESYSTEM_DRIVER=public_path
// If you use storage path in FILESYSTEM_DRIVER
// run this command
php artisan storage:link
# Using namespace
use RiseUpLabs\ImageCropper\Facades\ImageCrop;
// in the controller just define resizes array if you have to resize an image in multiple pieces
class ImageCropController extends Controller
{
// preferred size is set for uploading images
private $resizeArr = [
["width" => 50, "height" => 50],
["width" => 100, "height" => 100],
["width" => 200, "height" => 200],
["width" => 300, "height" => 300],
["width" => 400, "height" => 400],
["width" => 500, "height" => 500],
["width" => 600, "height" => 600],
["width" => 700, "height" => 700],
];
public function store(Request $request)
{
/**
* @param $file
* @param $folder_path ex: photos or album/photos
* @param $this->resizeArr (optional)
*/
$image_path = ImageCrop::perfect($request->file, "photos", $this->resizeArr);
// $image_path = ImageCrop::force($request->file, "photos", $this->resizeArr);
// $image_path = ImageCrop::crop($request->file, "photos", $this->resizeArr);
// $image_path = ImageCrop::original($request->file, "photos");
return $image_path;
}
}
// resize with force image
// Resize the image according to the defined height and width
$images = ImageCrop::force($request->file, "photos", $this->resizeArr);
$images = ImageCrop::forceWithOriginal($request->file, "photos", $this->resizeArr);
// resize with crop image
// Crop the image to the center point of the image
$images = ImageCrop::crop($request->file, "photos", $this->resizeArr);
$images = ImageCrop::cropWithOriginal($request->file, "photos", $this->resizeArr);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.