Is it possible to reduce image size proportionally by standard laravel methods, without third-party libraries? My way to upload images to the server
$path = $request->file('image')->store('uploads','public'); If anyone is interested in how I did:
Used Intervention
$file = $request->file('image'); //get filename with extension $filenamewithextension = $file->getClientOriginalName(); //get filename without extension $filename = pathinfo($filenamewithextension, PATHINFO_FILENAME); //get file extension $extension = $file->getClientOriginalExtension(); //filename to store $filenametostore = $filename.'_'.uniqid().'.'.$extension; \Storage::put('public/profile_images/'. $filenametostore, fopen($file, 'r+')); //Resize image here $thumbnailpath = public_path('storage/profile_images/'.$filenametostore); $img = Image::make($thumbnailpath); $height = $img->height(); $width = $img->width(); if($height >= 601) { $img->resize(300, null, function ($constraint) { $constraint->aspectRatio(); }); } if($width >= 601) { $img->resize(null, 300, function ($constraint) { $constraint->aspectRatio(); }); } $img->save($thumbnailpath);