TLeroy's avatar

Intervention - Image too big

Hi people.

I have a question about Intervention Image. I'm coding a gallery website, and I wanted to put an image from my phone, and I got an error :

"Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files."

My images are .jpg, but they have a resolution like 3024*4032 are a weight >2mo. I want to upload like 200-300 images on my website, so with these wieght that's gonna be a bit difficult.

So here, two questions, is my problem related to the weight of my images, or if not, how can I solve my error, and second, is there a way to modify my image before uploading it. Like my 3024*4032 image will be a 1240*1048 image.

If you have some ideas for me, thank you !

0 likes
4 replies
TLeroy's avatar

Hi, thank you for your response, I'll look at that.

Actually I'm using Intervention when I submit my form :

public function create(Request $request){
        $this->validate($request, [
            'nom' => 'required',
            'cover_image' => 'image'
        ]);

        $path = public_path() . "/images/".strtolower(str_replace(' ', '_', $request->nom));

        File::makeDirectory($path, $mode = 0777, true, true);
        Image::make($request->image)->fit(1280, 1024)->save(public_path() . "/images/".strtolower(str_replace(' ', '_', $request->nom))."/".str_replace(' ', '_', $request->nom)."_cover".".png");
        $final_img = str_replace(' ', '_', $request->nom)."_cover";

        Albums::create([
            'nom' => $request->nom,
            'description' => $request->description,
            'cover_image' => $final_img
        ]);

        session()->flash('album_succes');
        return redirect()->back();
    }

Is this type of js libraries obligatory or can I do something in this code with Intervention ?

Snapey's avatar
Snapey
Best Answer
Level 122

Intervention runs at the server which means the file must be small enough to handle server side, besides, you specifically asked;

is there a way to modify my image before uploading it.

Yes, with a client library for this purpose

BishoyWagih's avatar

i have the same issue although php.ini file max-file-size is 200M, any Updates.

Please or to participate in this conversation.