I'm using Image Intervention Library for image resizing, i've done the following steps:
1- Install Library: composer require intervention/image
2- Usage in code:
$file = $request->file('logo');
$destinationPath = 'db_images/public/';
$filename = $file->getClientOriginalName();
$extension = explode(".",$filename)[1];
$name = md5(microtime()).".".$extension;
$image_path = $destinationPath.$name;
$img = Image::make($filename)->resize(254, 179)->save($image_path);
$file->move($destinationPath,$img);
Issue Is: When i try to upload the file using the above code this will return me 'Image Source is not readable'.
Pleas help me in resolving this issue. Thanks
Your are passing only the filename to the make
method, you have to pass either the file object or the filepath:
file:
$img = Image::make($file)->resize(254, 179)->save($image_path);
path:
$img = Image::make($file->getRealPath())->resize(254, 179)->save($image_path);