ucraft-com/thumbnail-generator
Composer 安装命令:
composer require ucraft-com/thumbnail-generator
包简介
This PHP package provides a comprehensive solution for generating thumbnails from various file types, including images, videos, PDF documents, and audio files.
README 文档
README
Thumbnail Generator is a versatile Laravel package designed to create and manage thumbnails from various file types, including images, videos, audios, documents, and PDF files. This package provides a straightforward API to generate thumbnails and customize their dimensions and quality.
Features
- Multiple File Type Support: Generate thumbnails from images (JPEG, PNG, GIF), videos, audios, documents, and PDF files.
- WebP Support: Generate WebP thumbnails for better compression and faster load times.
- Customizable Dimensions: Specify the width and height of the thumbnails.
- Quality Control: Adjust the quality of the generated thumbnails to balance between size and visual fidelity.
- Aspect Ratio Maintenance: Automatically maintain the aspect ratio of the original media.
Requirements
- PHP: 8.1 or higher
- Imagick PHP extension: You need to have the Imagick PHP extension installed and enabled to use the ThumbnailGenerator package.
Installation
You can install the package via Composer:
composer require ucraft-com/thumbnail-generator
php artisan vendor:publish --provider="Uc\ThumbnailGenerator\ThumbnailGeneratorServiceProvider"
Basic Usage
Images
use Uc\ThumbnailGenerator\ThumbnailGeneratorFactory; $factory = new ThumbnailGeneratorFactory(...); $gen = $factory->createImageThumbnailGenerator(); $content = $gen->generate($file, 200, 200);
WebP Thumbnails
To generate WebP thumbnails, use the makeWebPAware method to decorate the ThumbnailGenerator instance:
use Uc\ThumbnailGenerator\ThumbnailGeneratorFactory; $factory = new ThumbnailGeneratorFactory(...); $gen = $factory->createImageThumbnailGenerator(); $webPGen = $factory->makeWebPAware($gen); // Generate a WebP thumbnail using a decorated instance [$content, $webPContent] = $webPGen->generate($file, 200, 200);
ucraft-com/thumbnail-generator 适用场景与选型建议
ucraft-com/thumbnail-generator 是一款 基于 Rich Text Format 开发的 Composer 扩展包,目前已累计 5.26k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 08 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ucraft-com/thumbnail-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ucraft-com/thumbnail-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-05