PHP code example of montesjmm / resize-and-watermark

1. Go to this page and download the library: Download montesjmm/resize-and-watermark library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

montesjmm / resize-and-watermark example snippets


$resizer = new ResizeAndWatermark;
$picture = $resizer->store('http://example.com/image.jpg');

echo $picture->html('small'); // <img src="http://mysite.com/uploads/2015/03/20150327-picture_small.jpg">

echo $picture->html('big'); // <img src="http://laravel5.app/uploads/2015/03/20150327-picture_big.jpg">

$resizer = new ResizeAndWatermark;
$file = Input::file()['file'];
$picture = $resizer->store($file);

echo $picture->html('small'); // <img src="http://mysite.com/uploads/2015/03/20150327-picture_small.jpg">

Route::get('/', 'WelcomeController@index');
Route::post('/', 'WelcomeController@index');

 namespace App\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Input;
use Montesjmm\ResizeAndWatermark\ResizeAndWatermark;

class WelcomeController extends Controller {

	public function index()
	{
		if (Request::isMethod('post')) {
			$resizer = new ResizeAndWatermark;

			$file = Input::file()['file'];

			$picture = $resizer->store($file);

			return '<img src="' . $picture->url('small') . '">';
		}

		return view('welcome');
	}
}