imranbru's avatar

Intervention Image v4 - "Call to undefined method Intervention\Image\ImageManager::read()" – What is the correct way now?

Hi everyone,

I'm facing a frustrating issue after upgrading to the latest Intervention Image v4 (with intervention/image-laravel package).

I keep getting this error:

Call to undefined method Intervention\Image\ImageManager::read()

I was using the Laravel facade like this:

use Intervention\Image\Laravel\Facades\Image;

$image = Image::read($uploadedFile);

But it doesn't work. Some older tutorials and even some parts of the docs still mention Image::decode() from v2.

My Questions:

  • Has the read() method been removed in the latest version?
  • Is Image::decode() the new/recommended way now?
  • What is the correct way to read an uploaded file ($request->file()) in Intervention Image v4 with the Laravel facade?

I'm also getting driver-related errors sometimes (Argument $driver must be existing class name), so any complete working example with proper config would be super helpful.

Has anyone successfully upgraded their image upload function to the latest version? Please share your working code (especially for resizing + thumbnail + saving with Laravel Storage or direct path).

Thanks in advance!


0 likes
4 replies
imranbru's avatar

yes, solution is: use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Intervention\Image\Laravel\Facades\Image;

Route::get('/', function (Request $request) { $upload = $request->file('image'); $image = Image::decode($upload) ->resize(300, 200);

Storage::put(
    Str::random() . '.' . $upload->getClientOriginalExtension(),
    $image->encodeUsingFileExtension($upload->getClientOriginalExtension(), quality: 70)
);

});

Jsanwo64's avatar

`Image::read()``` does NOT exist in v4

Most like the reson the error was returned

Call to undefined method ImageManager::read()

For version 4, the entry point is now Image::decode($input)

so the correct way would be;

For this error $driver must be existing class name

Publish config (if not already):

php artisan vendor:publish --tag=intervention-image-config

Then in config/image.php, set driver to

return [
    'driver' => \Intervention\Image\Drivers\Gd\Driver::class,
];

if you prefer Imagick

'driver' => \Intervention\Image\Drivers\Imagick\Driver::class,

Thumbnail example

$thumbnail = Image::decode($file)
    ->cover(150, 150); // better than resize for thumbnails

Storage::put(
    "uploads/thumbs/{$filename}",
    $thumbnail->encodeByExtension($extension, quality: 60)
);

Please or to participate in this conversation.