Search code examples
phplaravelintervention

Laravel - Using image intervention in Jobs. Path error


I'm trying to use image intervention in Jobs but it seems that the path is not correctly read. Meanwhile in a normal controller, it works. There are the codes in my job:

$img = Image::make('storage/app/picture/1.jpg)->resize(1280, 720);

It outputs this error:

Intervention \ Image \ Exception \ NotReadableException Image source not readable

But it does work when put in normal controller instead of jobs.

Is there any way I can solve this? Thank you


Solution

  • You could use path method of Storage facade.

    $img = Image::make(Storage::path('picture/1.jpg'))->resize(1280, 720);
    

    Or storage_path() helper:

    $img = Image::make(storage_path('app/picture/1.jpg'))->resize(1280, 720);
    

    It witll return absolute path to file.