imeysam/laravel-picsize
最新稳定版本:v2.0.1
Composer 安装命令:
composer require imeysam/laravel-picsize
包简介
This package helps developers to easily change images dimensions.
README 文档
README
✂️ Simple & Flexible Laravel Picsize
Laravel Picsize is a simple and flexible Laravel package that helps you to resize images on the fly, then store and reuse the resized versions — all with one line of code.
It’s designed for Laravel projects that need on-demand thumbnails, resized images, or optimized storage, without reinventing the wheel every time.
📋 Features
✅ Simple Facade: Picsize::resize($path, $width, $height)
✅ Disk-based storage (local, public, S3, FTP, etc.)
✅ Automatic fallback image if source is missing
✅ Respects Laravel’s Filesystem & URL helpers
✅ Auto-creates output folders with proper permissions (local disks)
✅ Compatible with Laravel 9.x – 12.x
⚙️ Requirements
- PHP >= 8.1
- Laravel >= 9.x
- Intervention Image (included)
🚀 Installation
Install the package via Composer:
composer require imeysam/laravel-picsize
🔧 1️⃣ Add & Customize Config
By default, the package uses these settings:
disk→publicinput_path→uploadsoutput_path→imagesfallback_image→images/default.jpg
To customize these, publish the config file.
You can do this in two ways:
Option 1 — Using the Provider name (recommended)
php artisan vendor:publish --provider="Imeysam\Picsize\Providers\PicsizeServiceProvider"
Option 1 — Using the tag config
php artisan vendor:publish --tag=config
config/picsize.php
return [ 'disk' => 'public', 'input_path' => 'uploads', 'output_path' => 'images', 'fallback_image' => 'images/default.jpg', ];
✨ Usage
Once installed and configured, using the picsize is super simple.
You can call the resize method using the Facade, or inject the service into your classes.
📌 Basic Using
use Imeysam\Picsize\Facades\Picsize; class ImageController extends Controller { public function show() { // Resize to 400x300 and get the full URL $url = Picsize::resize('photos/test.jpg', 400, 300); ... } }
🧩 Using Dependency Injection
use Imeysam\Picsize\Picsize; class ImageController extends Controller { public function show(Picsize $picsize) { // Resize to 400x300 and get the full URL $url = $picsize->resize('photos/test.jpg', 400, 300); ... } }
⚡ Using In Blade
<img src="{{ Picsize::resize('photos/test.jpg', 400, 300) }}">
⚖️ License
- This package is created for Laravel >= 9.x and is released under the MIT License and, based on Intervention Image.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-30