skip to Main Content

I’m new to Laravel, I use Intervention Image on laravel 10.39.0, but it is getting error,
Class "InterventionImageFacadesImage" not found

This is the code.

This is the code.

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use InterventionImageFacadesImage;


class HomeController extends Controller
{
    public function index(){
        return view('home');
    }

    public function test(){
        // Open an image file
        $img = Image::make('uploads/img1.jpg');
        $img->crop(300,300);
        $img->save(public_path('uploads/corp_img1.jpg'));
        
    }
}

error is showing on this line: $img = Image::make(‘uploads/img1.jpg’);
"intervention/image": "^3.2",
PHP: PHP 8.2.10-2ubuntu1

How to solve this issue?

2

Answers


  1. Chosen as BEST ANSWER

    After a couple of hours, I found the answer, this code might be helpful to others.

    <?php
    
    namespace AppHttpControllers;
    
    use IlluminateHttpRequest;
    use InterventionImageImageManager;
    use InterventionImageDriversGdDriver;
    
    
    class HomeController extends Controller
    {
        public function index() 
        {
            return view('home');
        }
    
        public function test() 
        {
            // create image manager with desired driver
            $manager = new ImageManager(new Driver());
    
            // read image from file system
            $image = $manager->read('uploads/image.jpeg');
            // Image Crop
            $image->crop(500,500);
            // insert watermark
            $image->place('uploads/water_mark.png');
            //Save the file
            $image->save(public_path('uploads/crop.jpeg'));
        }
    }
    

  2. First check the intervention/image is installed correctly you can check first this directory vendor/intervention/image or composer show intervention/image.
    if you can see this directory try this commands composer dump-autoload.
    then you can try to clear cache php artisan cache:clear after that try again and check is problem exists.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search