PHP code example of mindshaker / image-upload

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/ */

    

mindshaker / image-upload example snippets


return [
    'public_path' => 'uploads',
    'random_name' => true,
];

'private' => [
    'driver' => 'local',
    'root' => storage_path('app/upload_folder'),
    'url' => env('APP_URL') . '/storage',
    'visibility' => 'private',
    'throw' => false,
],

use Mindshaker\ImageUpload\Facades\ImageUpload;

ImageUpload::upload($image, $width = null, $height = null, $crop = false, $private = false);

ImageUpload::path("additional_path");

ImageUpload::name("image_name");

ImageUpload::format("jpg");

ImageUpload::quality(75);

$image_name = ImageUpload::upload($image, 1920);

ImageUpload::delete($image_name);

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();
bash
$ php artisan vendor:publish --provider="Mindshaker\\ImageUpload\\ImageUploadServiceProvider"