Home » Laravel 5.8 Image Resize Tutorials

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.

Read Also:  Set flashdata(set_flashdata) in codeigniter Example

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 :

Read Also:  set operations sql

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  FullCalendar - Vuejs Event Calendar Component
  2. Read Also:  Laravel Resize Image Before Upload Example
  3. Read Also:  PHP Laravel Inline CRUD Using jQuery and AJAX
  4. Read Also:  VueJS String substring() Method
  5. Read Also:  PHP Laravel get months between two dates
  6. Read Also:  How to Find the Document Root using PHP Script
  7. Read Also:  How to Get Current Date & Time in JavaScript
  8. Read Also:  How to update multiple rows of multiple column in sql?
  9. Read Also:  Laravel Ajax Autocomplete Search Box Example
  10. Read Also:  Laravel Ajax Autocomplete Search Box Example

Leave a Comment

Your email address will not be published. Required fields are marked *