1. Go to this page and download the library: Download mindshaker/image-upload 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 Mindshaker\ImageUpload\Facades\ImageUpload;
$image = $request->file('image');
//Simple upload ($width or $height needs to be specified)
//It will resize the image to 1920px. It won't upscale
ImageUpload::upload($image, 1920);
//Crop the image to the given dimensions
ImageUpload::upload($image, 512, 512, true);
//Change the format of the image
ImageUpload::format("webp")->upload($image, 1920);
//Add aditional path and change name
ImageUpload::path("posts/{id}")->name("post_name")->format("webp")->upload($image, 1920, null);
//returns something like "posts/1/post_name.webp"
ImageUpload::manager($image);
use Mindshaker\ImageUpload\Facades\ImageUpload;
$image = $request->file('image');
ImageUpload::manager($image)->pad(512, 512, 'ccc')->format("png")->save();