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

Chrizzmeister's avatar

Using Laravel 5.3 storage with Canvas() from intervention Image

Running Laraval 5.4 with Vagrant and Homestead.

Saw a few other questions regarding this issue but none provided a solution which uses the canvas() method by Intervention/Image

My current code:

$path = $request->file('logo')->store('/clients/logos','public');

$canvas = Image::canvas($width, $height);
$image = Image::make($path)->resize($width, $height, function ($constraint)
{
    $constraint->aspectRatio();
});

$canvas->insert($image, 'center');
$canvas->save($path);

$this->logo_path = $path;

This code creates a canvas and places a resized image inside it.

This code gives following error:

NotReadableException in AbstractDecoder.php line 335: Image source not readable in AbstractDecoder.php line 335 at AbstractDecoder->init('clients/logos/UupUn1iuDGRsy5Z0bkWHJ6S4v79bfZiXapTO7vLk.jpeg') in AbstractDriver.php line 64

The first line works, because the image is stored inside my storage folder at the following location:

"/storage/app/public/clients/logo/UupUn1iuDGRsy5Z0bkWHJ6S4v79bfZiXapTO7vLk.jpeg"

but the image is stored in full-size, so the code fails at the image-intervention part.

Things i tried: I tried changing the $path variable inside Image::make() to this:

Storage::disk('public')->url($path)

which results in following error: Can't write image data to path

(http://test.dev/storage/clients/logos/owjNA5Fn9QyYoS0i84UgysaFLo5v0NzbOiBhBzXp.jpeg)

The weird part about that error is that the 'app' directory is not visible inside that error.

I'm running out of ideas to solve this issue.

0 likes
1 reply
Chrizzmeister's avatar
Chrizzmeister
OP
Best Answer
Level 19

This was the answer

$path = $request->file('logo')->store('/clients/logos','public');

// creating a canvas
$canvas = Image::canvas($width, $height);


$image = Image::make(storage_path("app/public/" . $path))->resize($width, $height, 
    function ($constraint) {
        $constraint->aspectRatio();
});

$canvas->insert($image, 'center');

// pass the full path. Canvas overwrites initial image with a logo
$canvas->save(storage_path("app/public/" . $path . ".png"));
``

Please or to participate in this conversation.