smorken/image-sizer
最新稳定版本:v10.2.0
Composer 安装命令:
composer require smorken/image-sizer
包简介
Helper library for image sizing
README 文档
README
License
This software is open-sourced software licensed under the MIT license
The Laravel framework is open-sourced software licensed under the MIT license
Requirements
- PHP 7.2+
- PHP GD library
- Composer
Use
Can be used standalone or with Laravel 6
- add service provider to
config/app.php
'providers' => [
...
Smorken\Image\Sizer\ServiceProvider::class,
Creating a resized image:
$stream = fopen('foo_image.png', 'r+');
//$string = file_get_contents('foo_image.png');
$sizer = app('Smorken\Image\Sizer\Contracts\Sizer');
$data = $sizer->size($stream);
$data = $sizer->size($stream, ['output' => 'png', 'base64' => true]);
return response()->make(
$data['data'],
200,
[
'Content-Type' => $data['mime'],
'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' => 'inline',
'Expires' => gmdate('D, d M Y H:i:s \G\M\T', time() + 86400),
'Cache-Control' => 'max-age=86400, public',
'Pragma' => 'public',
]
);
Data array:
'mime' => 'image/jpg',
'data' => binary_string, //(or base64 encoded string if base64 is true)
'size' => 12345,
Default config settings:
'height' => 200,
'width' => 200,
'option' => 'auto',
'output' => 'jpg',
'base64' => false,
统计信息
- 总下载量: 1.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-27