डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

Laravel intervention image open source package

With laravel livewire

composer require intervention/image

At config/app.php add provider and alias

Intervention\Image\ImageServiceProvider::class
'Image' => Intervention\Image\Facades\Image::class

Livewire code

<?php
namespace App\Http\Livewire;
use Livewire\Component;
use Livewire\WithFileUploads;
use Image;
class ImageTest extends Component
{
     use WithFileUploads;
    public $image;
    
    public function render()
    {
        return view('livewire.image-test')->extends('templates.public_layout');
    }
    public function upload(){
        $this->validate([
            'image' => 'image|max:3000', // 1MB Max
        ]);
       $path = $this->image->store("temp","public");
        
        Image::make($this->image)
        ->resize(100, null, function ($constraint) {
                $constraint->aspectRatio();
            })
        ->save(storage_path()."/app/public/raw/first.jpg");
    }
}
 
© 2016 - 2023, All Rights are Reserved.