Yousef Altaf
Yousef Altaf

Reputation: 2763

Laravel 5.2: create image thumbnails in using intervention

I am trying to create image thumbnails using intervention here is my controller

if ($request->hasFile('image')) {
            $image = $request->file('image');
            $filename = time() . '.' . $image->getClientOriginalExtension();
            Image::make($image)->resize(600, 390)->save(public_path('images/blog/' . $filename));
            $image->fit(240, 157)->save(public_path('images/blog/' . $filename . '-thumbs.jpg'));
            $add->image = $filename;
        }

Got

Method fit does not exist.

What I am doing wrong here?

Upvotes: 0

Views: 3139

Answers (1)

Jomoos
Jomoos

Reputation: 13083

You have to update this line:

Image::make($image)->resize(600, 390)->save(public_path('images/blog/' . $filename));

to

$image = Image::make($image)->resize(600, 390)->save(public_path('images/blog/' . $filename));

because fit is a method of InterventionImage object.

Upvotes: 1

Related Questions