sanjay23's avatar

Unable to init from given binary data | Intervention | Laravel 5.6

Hello,

I am using the image intervention library to store my images and convert them with the proper size.

Let's say I have uploaded one 5MB image which is stored in the base folder then, We have to take that original image and crop them in various sizes for this purpose we used the following code

$img = Image::make(asset('assets/images/sample.png'));
$img->crop(3000,4000,100,200);
$img->fit(500, 625);
$img->save(Storage path);

However, it giving me the error like -

{message: "Unable to init from given binary data.",…}
exception: "Intervention\Image\Exception\NotReadableException"
file: "/public_html/project/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php"
line: 113

We have tried by sending URL path and Storage path too but same error.

Any would be appreciable.

Thank you

0 likes
3 replies
Tray2's avatar
  • Have you checked the permissions on the image file?
  • Do you have the images stored in assets('assets/images' and not assets('images')?
sanjay23's avatar

@Tray2 I have checked the permission for the folders,

The image is stored in storage/app/public/profile/sample.php and it has 777 permission

Snapey's avatar

Asset helper returns a URL. You don't want a URL when working with files, you want a PATH that the filesystem can understand

try storage_path instead

$img = Image::make(storage_path('assets/images/sample.png'));

adjust your path to suit, I doubt it is storage/app/public/profile/sample.php because thats a php file

1 like

Please or to participate in this conversation.