siaoynli/laravel-images
Composer 安装命令:
composer require siaoynli/laravel-images
包简介
laravel compress images package
README 文档
README
install
this package for laravel
composer require siaoynli/laravel-images
add the ServiceProvider to the providers array in config/app.php
Siaoynli\Image\ImageServiceProvider::class,
If you want to use the facade to log messages, add this to your facades in app.php:
'Image' => Siaoynli\Image\Facades\Image::class,
Copy the package config to your local config with the publish command:
php artisan vendor:publish --provider="Siaoynli\Image\ImageServiceProvider"
Usage
use Siaoynli\Upload\Facades\Upload;
use Siaoynli\Image\Facades\Image;
//upload
$info=Upload::do()
... //if upload success
//图片源文件存储在public目录
//使用相对路径
$filename = $info["url"];
Image::file('.'.$filename)->resize(1500)->save();
////使用绝对路径的文件
$filename = public_path($info["url"]);
Image::file($filename)->resize(1500)->save();
//thumb
Image::file($filename)->resize()->water()->save()
//small image
$small=Image::file($filename)->small()
//resize
Image::file($filename)->resize()->save()
//crop center
Image::file($filename)->crop()->save()
//water
Image::file($filename)->water()->save()
Image::file($filename)->water(public_path("/water/logo.png","bottom-right",20,20)->save("",80)
//压缩图片
Image::file(storage_path("app" . $filename))->resize(1500)->save();
//源文件存储到storage里,打水印和生成小图在 public 目录
Image::file(storage_path("app".$filename))->crop()->small($small_filename,150);
Image::file(storage_path("app".$filename))->resize()->water()->save(public_path($filename));
//存储为其他文件
$new_filename=storage_path($filename);
Image::file($filename)->water()->save($new_filename,90)
Result
//upload result
array:6 [▼
"state" => "SUCCESS"
"original_name" => "0eb30f2442a7d9337afbe24aa94bd11373f001b3.jpg"
"ext" => "jpg"
"mime" => "image/jpeg"
"size" => 130759
"url" => "/uploads/image/2019-07-10/b40383942859e40ee1f1eb3dd889e01d9b68dcb5.jpg"
]
//upload error
[
"state"=>"error message"
]
// thumb result
"/uploads/image/2019-07-10/b40383942859e40ee1f1eb3dd889e01d9b68dcb5.jpg"
siaoynli/laravel-images 适用场景与选型建议
siaoynli/laravel-images 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 198 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 siaoynli/laravel-images 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 siaoynli/laravel-images 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 198
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-19