montesjmm/resize-and-watermark
Composer 安装命令:
composer require montesjmm/resize-and-watermark
包简介
Resize and Watermark for Laravel resizes and watermarks your pictures easily
README 文档
README
#Resize And Watermark (images) Easily automate picture upload, generating of multiple sizes and watermarking if needed.
##Laravel 5.2 Installation
- Add to your composer require: "montesjmm/resize-and-watermark": "~0.3"
- Add service provider to your config/app.php: Montesjmm\ResizeAndWatermark\ResizeAndWatermarkServiceProvider::class,
- Add alias to your config/app.php aliases: 'ResizeAndWatermark' => Montesjmm\ResizeAndWatermark\ResizeAndWatermark::class,
- composer update
- php artisan vendor:publish
- php artisan migrate
- composer dump-autoload -o
- php artisan db:seed --class=RwPicturesSizesTableSeeder
##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">
Example App
####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.
Config
at config/resize-and-watermark.php you can setup the routes for the watermarking files if you want watermarking.
montesjmm/resize-and-watermark 适用场景与选型建议
montesjmm/resize-and-watermark 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 202 次下载、GitHub Stars 达 2, 最近一次更新时间为 2014 年 08 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「thumbnail」 「resize」 「watermark」 「picture resize」 「picture thumbnail」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 montesjmm/resize-and-watermark 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 montesjmm/resize-and-watermark 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 montesjmm/resize-and-watermark 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Powerful PHP class using GD library to work easily with images including layer notion (like Photoshop or GIMP)
Powerful PHP class using GD library to work easily with images including layer notion (like Photoshop or GIMP)
A PHP library for fetching thumbnails from a URL
Image cache
Image manipulation library for Laravel 8 based on Imagine and inspired by Croppa for easy url based manipulation
The lireincore/imgcache integration for the Yii2 framework
统计信息
- 总下载量: 202
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-19