wizzou/laravel-image-optimizer
Composer 安装命令:
composer require wizzou/laravel-image-optimizer
包简介
A Laravel package to efficiently resize and optimize images, supporting multiple storage backends including local file systems and cloud storage like Amazon S3.
README 文档
README
The wizzou/laravel-image-optimizer package provides a convenient solution for dynamically resizing and optimizing images in Laravel applications. It automates the process of image resizing, optimizing file sizes, and storing images in different storage backends such as local filesystems or cloud storage services like Amazon S3.
Installation
You can install the package via Composer. Run the following command in your terminal:
composer require wizzou/laravel-image-optimizer
After installing the package, the ImageOptimizer service will be available for use in your Laravel application.
Configuration
Publish the configuration file using the following Artisan command:
php artisan vendor:publish --provider="Wizzou\ImageOptimizer\ImageOptimizerServiceProvider"
This will create a config/image-optimizer.php file where you can configure the package settings.
Configuration Options
The configuration file allows you to customize various aspects of the image optimization process:
- Default Quality: The default quality setting (0-100) for image compression.
- Storage Disk: The disk where optimized images will be stored (e.g.,
public,s3). - Storage Path: The directory path within the chosen disk where images will be stored.
- Default Format: The default file format for image conversion (e.g.,
webp,jpg,png).
Modify these settings according to your application's requirements.
Usage
You can use the ImageOptimizer service to resize and optimize images in your Laravel application. Here's how you can use it in your code:
use Wizzou\ImageOptimizer\Facades\ImageOptimizer; // Resize and optimize an image $imageUrl = 'example.jpg'; $resizedImageUrl = ImageOptimizer::resize($imageUrl, 800, 600);
or
{{-- Example Blade Template --}} <img src="{{ ImageOptimizer::resize('example.jpg', 800, 600) }}" alt="Resized Image">
The resize method accepts the URL of the original image, as well as the desired width and height for the resized image. Optionally, you can specify the desired file format for the resized image as the fourth parameter.
Contributing
If you have suggestions for how this package could be improved, or if you've found a bug, please open an issue on GitHub.
Pull requests are also welcome! Please ensure that your code adheres to the PSR-12 coding standard and includes appropriate tests.
License
The wizzou/laravel-image-optimizer package is open-source software licensed under the BSD-2-Clause.
wizzou/laravel-image-optimizer 适用场景与选型建议
wizzou/laravel-image-optimizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wizzou/laravel-image-optimizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wizzou/laravel-image-optimizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2024-04-15