Reputation: 2787
I upgraded from Laravel 4.2 to Laraveld5.3 with intervention/image : "^2.3",
if (Input::hasFile('logo')) {
$path = public_path()."/assets/admin/layout/img/";
File::makeDirectory($path, $mode = 0777, true, true);
$image = Input::file('logo');
$extension = $image->getClientOriginalExtension();
$filename = "logo.$extension";
$filename_big = "logo-big.$extension";
Image::make($image->getRealPath())->save($path.$filename);
Image::make($image->getRealPath())->save($path.$filename_big);
$data['logo'] = $filename;
}
The result Is, got the error below:
Call to undefined method Intervention\Image\Facades\Image::make()
Upvotes: 6
Views: 28240
Reputation: 1070
If you're using intervention/image V3 then make
is replaced with read
https://image.intervention.io/v3/introduction/upgrade
Upvotes: 0
Reputation: 1
public function optimizeFile(Request $request)
{
$data = $request->file('image');
// dd($data);
if ($request->hasFile('image')) {
foreach($data as $key => $val){
$path=storage_Path('app/public/');
$filename='image-'.uniqid().$key.'.'.'webp';
$val->move($path,$filename);
$p['image']=$filename;
$insert[$key]['image'] = $filename;
//Resize image here
$thumbnailpath[$key]['abc'] = storage_path('app/public/'.$filename);
$img = Image::make($thumbnailpath)->resize(400, 150, function($constraint) {
$constraint->aspectRatio();
});
$img->save($thumbnailpath);
}
return redirect('ROUTE_URL')->with('success', "Image uploaded successfully.");
}
}
Upvotes: 0
Reputation: 630
Intervention\Image\ImageServiceProvider::class,
in providers array and add
'Image' => Intervention\Image\Facades\Image::class,
in aliases array.
php artisan config:cache
command.
use Image;
before class definition.
$imageHeight = Image::make($request->file('file'))->height();
Upvotes: 0
Reputation: 78
Make Sure that In config/app update Providers with
Intervention\Image\ImageServiceProvider::class
and update aliases with
'Image' => Intervention\Image\Facades\Image::class,
Upvotes: 2
Reputation: 4814
I experienced the same issue in my Laravel 5.4 project. I stumble on this link
that help resolve the issue. This was the fix that was provided
In config/app change 'aliases' for Image from
'Image' => Intervention\Image\Facades\Image::class,
To
'Image' => Intervention\Image\ImageManagerStatic::class,
Then in your controller header add
use Image;
Upvotes: 22