Package Data | |
---|---|
Maintainer Username: | montesjmm |
Maintainer Contact: | javier@montesjmm.com (Montes) |
Package Create Date: | 2014-05-24 |
Package Last Update: | 2016-03-16 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-13 15:00:48 |
Package Statistics | |
---|---|
Total Downloads: | 185 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
#Resize And Watermark (images) Easily automate picture upload, generating of multiple sizes and watermarking if needed.
##Laravel 5.2 Installation
##Examples
####Download and generate sizes from image url
$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">
####Generate sizes of form uploaded image
$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">
####app/Http/routes.php
Route::get('/', 'WelcomeController@index');
Route::post('/', 'WelcomeController@index');
####app/Http/controllers/WelcomeController.php
<?php 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');
}
}
####resources/views/welcome.blade.php
<html>
<head>
<title>Resize And Watermark Test</title>
</head>
<body>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="_token" value="{{{ csrf_token() }}}">
<input type="file" name="file">
<input type="submit" value="send">
</form>
</body>
</html>
When you upload a picture this will be the result in disk:
private-uploads/2015/03/20150326-picture_orig.jpg
public/uploads/2015/03/20150326-picture_bigger.jpg
public/uploads/2015/03/20150326-picture_big.jpg
public/uploads/2015/03/20150326-picture_medbig.jpg
public/uploads/2015/03/20150326-picture_medium.jpg
public/uploads/2015/03/20150326-picture_small.jpg
public/uploads/2015/03/20150326-picture_thumb.jpg
public/uploads/2015/03/20150326-picture_tiny.jpg
"laravel/private-uploads" and "laravel/public/uploads" must be writable.
at config/resize-and-watermark.php you can setup the routes for the watermarking files if you want watermarking.