Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

Laravel 5.8 Image Resize Tutorials

Today, We want to share with you Laravel 5.8 Image Resize Tutorials.In this post we will show you PHP Laravel 5.8 Intervention image upload and resize tutorial, hear for Upload and Resize Multiple Images in Laravel 5.8 we will give you demo and example for implement.In this post, we will learn about Resize Images in Laravel 5.8 with Spatie Media Library with an example.

Laravel 5.8 Image Resize Tutorials

There are the Following The simple About Laravel 5.8 Image Resize Tutorials Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel Image Resize and Upload Tutorial With Example, so the laravel intervention image upload for this example is following below.

  8 Useful PHP Tips Tricks and Best Practices

Step 1: Laravel 5.8 Installation

configure with Installation intervention/image library

composer require intervention/image

config/app.php Update (service provider && aliases )

'Intervention\Image\ImageServiceProvider'
'Image' => 'Intervention\Image\Facades\Image'

Step 2: Define Laravel 5.8 Route

app/Http/routes.php

    Route::get('intervention-resizeImage',['as'=>'intervention.getimgmanipulation','uses'=>'[email protected]']);
    Route::post('intervention-resizeImage',['as'=>'intervention.uploadedimagesresize','uses'=>'[email protected]']);
	

Step 3: Update Laravel 5.8 Controller

app/Http/Controllers/ImgManipulationController.php

    <?php
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use App\Http\Controllers\Controller;
    use Image;
    class ImgManipulationController extends Controller {
        public function getResizeImage()
        {
            return view('files.imgmanipulation');
        }
        public function uploadedimagesresize(Request $request)
        {
            $this->validate($request, [
                'photo' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:1024',
            ]);
            $photo = $request->file('photo');
            $new_file_name = time().'.'.$photo->getClientOriginalExtension(); 
       
            $finalUploadedPath = public_path('/upload_media_img');
            $thumb_img = Image::make($photo->getRealPath())->resize(100, 100);
            $thumb_img->save($finalUploadedPath.'/'.$new_file_name,80);
                        
            $finalUploadedPath = public_path('/profiles');
            $photo->move($finalUploadedPath, $new_file_name);
            return back()
                ->with('success','Good Luck, Your Image Upload successful')
                ->with('new_file_name',$new_file_name);
        }
    }

Step 4: Create Laravel Blade file

resources/views/files/imgmanipulation.blade.php

    @extends('layouts.default')
    @section('content')
    <div class="panel panel-success">
     <div class="panel-heading">Laravel 5.8 Intervention upload image after resize Example - step by step</div>
      <div class="panel-body"> 
        @if (count($errors) > 0)
        <div class="alert alert-danger">
            @foreach ($errors->all() as $error)
              <p class="error_item">{{ $error }}</p>
            @endforeach
        </div>
        @endif
        @if (Session::get('success'))
        
        <div class="pakainfo row">
            <div class="dsp col-md-12">
            <div class="dsp col-md-4">
                <strong>Image Before Resize:</strong>
            </div>
            <div class="col-md-8">    
                <img src="{{asset('profiles/'.Session::get('new_file_name')) }}" />
            </div>
            </div>
            <div class="dsp col-md-12" style="margin-top:12px;">
            <div class="dsp col-md-4">
                <strong>Image after Resize:</strong>
            </div>
            <div class="dsp col-md-8">    
                <img src="{{asset('upload_media_img/'.Session::get('new_file_name')) }}" />
            </div>
            </div>
        </div>
        @endif
        {!! Form::open(array('route' => 'intervention.uploadedimagesresize','files'=>true)) !!}
            <div class="row">
            
                <div class="col-md-6">
                    <br/>
                    {!! Form::file('photo', array('class' => 'form-control')) !!}
                </div>
                <div class="col-md-6">
                    <br/>
                    <button type="submit" class="btn btn-success">Upload Your Image</button>
                </div>
            </div>
        {!! Form::close() !!}
     </div>
    </div>
    @endsection

Angular 6 CRUD Operations Application Tutorials

Read :

  check Element Hidden in jQuery

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel 5.8 Image Resize Tutorials.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.