Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cyberomin's avatar

Intervention Image and Laravel 5.1

Hi everyone,

I am having issues with my Intervention image package. I added the following to my aliases and providers

'providers' => [
    Intervention\Image\ImageServiceProvider::class
],

'aliases' => [
    'Image'     => Intervention\Image\Facades\Image::class
],

I import the class using

use Intervention\Image\Image as Image;

Problem is when I call the make static function

Image::make, I get an error - FatalErrorException in Image.php line 101: Call to a member function executeCommand() on a non-object

What am I missing?

0 likes
8 replies
Kryptonit3's avatar

If you are using the facade then you don't need to import the class like that.

Just do this

<?php

use Image;

class Blah
{

    public function image()
    {
        Image::make($blah);
    }

}
cyberomin's avatar

Hi @opheliadesign here is some code

use Intervention\Image\Image as Image;

public function postUploadPassport(PassportRequest $request, Image $image) 
    {
        $file           = $request->file('passport');
        $ext            = $file->getClientOriginalExtension();
        $allowed_ext    = ['jpg', 'png', 'gif', 'jpeg'];
        $image_data     = $image->make(120, 90);
        $size           = round($image_data->filesize() / (pow(self::MEGABYTE, 2)));
}

Everything breaks around - $image_data

Hey @Kryptonit3 Going that route gives the same problem.

opheliadesign's avatar

@cyberomin it looks like you're passing integers (presumably image dimensions) where it's expecting a file or URL?

// open an image file
$img = Image::make('public/foo.jpg');

// now you are able to resize the instance
$img->resize(320, 240);

// and insert a watermark for example
$img->insert('public/watermark.png');

// finally we save the image as a new file
$img->save('public/bar.jpg');
cyberomin's avatar

@opheliadesign apologies man, the code I posted is wrong. From your sample code, the first line Image::make doesn't seem to work for me.

opheliadesign's avatar

@cyberomin that's code from the Intervention documentation - have you read through it? Perhaps post the correct code? :)

SaifHarbia's avatar

you should include this line: use Intervention\Image\ImageManagerStatic as Image;
instead of your line: use Intervention\Image\Image as Image;

1 like
thomaskim's avatar

Several things.

  1. I'd recommend just using the Facade like @Kryptonit3 said, which means importing use Image;

  2. You don't pass integers to the make method. Try something like this:

// Import at top
use Image;

// Make image like this
$file = $request->file('passport');
$img = Image::make($file->getRealPath());
$img->save(public_path('bla.jpg'));

Read the docs to learn more about other features.

http://image.intervention.io/

2 likes

Please or to participate in this conversation.