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

mallaury's avatar

Intervention\Image : Image source not readable

Hello, I'm experiencing a problem (in some cases, but not always...). I can't reproduce the problem so I need help.

Here is the function

public function storeMedia(Request $request)
    {
        $path = public_path('uploads');

        if (!file_exists($path)) {
            mkdir($path, 0777, true);
        }

        $image = $request->file('file');
        $input['image_name'] = Str::lower(Str::uuid()) . '.' . $image->getClientOriginalExtension();

        $height = 1200;
        $width = 1200;
        $img = \Intervention\Image\Facades\Image::make($image->path()); // THIS LINE SOMETIMES THROWS AN EXCEPTION

        $img->height() > $img->width() ? $width = null : $height = null;
        $img->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
        });
        $img->orientate();

        $img->save($path . '/' . $input['image_name']);

        return $input['image_name'];
    }

The exception is :

(Intervention\Image\Exception\NotReadableException(code: 0): Image source not readable

In 95% of cases everything works fine, so I don't think it's a path or permission problem.

Thansk!

0 likes
2 replies

Please or to participate in this conversation.