Image Processing Component

intervention/image

Project link

https://github.com/Intervention/image

Installation

composer require intervention/image

Usage

Upload page fragment

  <form method="post" action="/user/img" enctype="multipart/form-data">
      <input type="file" name="file">
      <input type="submit" value="Submit">
  </form>

Create app/controller/UserController.php

<?php
namespace app\controller;
use support\Request;
use Intervention\Image\ImageManagerStatic as Image;

class UserController
{
    public function img(Request $request)
    {
        $file = $request->file('file');
        if ($file && $file->isValid()) {
            $image = Image::make($file)->resize(100, 100);
            return response($image->encode('png'), 200, ['Content-Type' => 'image/png']);
        }
        return response('file not found');
    }

}

More Information

Visit http://image.intervention.io/getting_started/introduction