danilchican's avatar

Laravel Intervention/Image: Unable to init from given binary data.

Hi everyone! I faced with the issue when I tried to use laravel intervention/image package. I have a Service class which have method with following logic e.g.:

        return Image::make($imageUrl);

And I have console command which calls the service method. The problem is that if I execute artisan custom command everything is ok. But when I try to use this service inside controller it fails with the following error:

Intervention\Image\Exception\NotReadableException
Unable to read image from binary data.

Intervention\Image\Imagick\Decoder::initFromBinary
...\mysite.local\vendor\intervention\image\src\Intervention\Image\Imagick\Decoder.php:90

$imageUrl is equal to http://somesite.com/image.jpg.

Can you help me with that? No idea what happens.

0 likes
7 replies
Tray2's avatar

I would say this is your issue.

Unable to read image from binary data.

I think it has to do with the fact that it doesn't find the file you are passing to it.

If you do this

if (file_exists($imageUrl) {
	return Image::make($imageUrl);
}

dd('Couldn't find the image');

Your output most likely will be

Couldn't find the image

danilchican's avatar

file_exists doesn't work for file provided by url

danilchican's avatar

If I'm trying to use Image::make($request->file('image')) then I get the error like Unable to read image from path (D:\...\tmp\phpD64B.tmp)

Tray2's avatar

Show your full code for the store method.

danilchican's avatar

I have found the root cause of the issue. The problem is not reproduced on Stage environment. It's reproduced only in local env. The expected root cause is that there are no image formats installed locally to recognize.

Please or to participate in this conversation.