sz4h/image
Composer 安装命令:
composer require sz4h/image
包简介
This image on the fly resize package
README 文档
README
This package simplifies the resized version of stored images. It's support both local images and remote ones. It uses the intervention/image.
Requirements
- PHP >= 8.0
- fileinfo php extension
- GD Library OR Imagick PHP extension
Todo
Apply some kind of cache mechanism on top of the resize core
Installation
You can install the package via composer:
composer require sz4h/image
You should publish the config/assets file with:
php artisan vendor:publish --tag="image-config" php artisan vendor:publish --tag="image-assets"
This is the contents of the published config file:
// config for Space/Image return [ 'route' => [ /* * The route domain used for on fly resize (Can be helpful in multi-tenant system) */ 'domain' => false, /* * The route name used for on fly resize */ 'name' => 'resize', /* * The route prefix used for on fly resize */ 'prefix' => 'resize', /* * The middlewares for resize route */ 'middlewares' => [ 'web', ], ], 'watermark' => [ /* * Watermark image path * You may need to do a vendor:publish --tag=space-watermark * Or Add the watermark image into the provided path * If you face an Exception on type CouldNotRetrieveWatermark */ 'image' => public_path('vendor/image/watermark.png'), /* * Watermark image position on the image * Accepted values are: * bottom-center * bottom-right * bottom-left * top-center * top-right * top-left * center-center * center-left * center-right */ 'position' => 'bottom-right', /* * Offset horizontally of the watermark can be positive or negative value */ 'offsetX' => 10, /* * Offset vertically of the watermark can be positive or negative value */ 'offsetY' => 10, /* * Percentage ratio between the resized image and the watermark */ 'ratio' => 0.20, ], /* * Presets for faster sizes creations * Param: * w => width of the image (Type: integer) * h => height of the image (Type: integer) * crop => used to allow cropping (Type: boolean) * retain => used to retain the aspect ratio of the image. If used with the crop then the crop will determinate the nearest value for both width and height (Type: boolean) * bg => background color in hex format (Type: string) * watermark => used to allow watermark of the image (Type: boolean) */ 'presets' => [ 'thumbnail' => 'w=150&h=150&crop=true&retain=false&bg=ffffff&watermark=false', 'medium' => 'w=300&h=300&crop=true&retain=true&bg=ffffff&watermark=false', 'large' => 'w=1024&h=1024&crop=true&retain=true&bg=ffffff&watermark=true', ], /* * Define the fallback image if the image not found */ 'not_found_image_path' => public_path('vendor/image/not-found.png'), /* * Default values */ 'default' => [ 'w' => 200, 'h' => 200, 'crop' => true, 'retain' => true, 'bg' => null, 'watermark' => false, ], ];
Usage
echo resize_url( 'storage/default/1/2022-08-15-9d5862c703.png', 'thumbnail', [ 'retain' => true, 'crop'=> true, 'watermark'=> true, 'bg'=> 'ff6666', ] ); echo resize_url( 'storage/default/1/2022-08-15-9d5862c703.png', '300x200' );
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
sz4h/image 适用场景与选型建议
sz4h/image 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 125 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「laravel」 「space」 「sz4h」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sz4h/image 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sz4h/image 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sz4h/image 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Public Space Plugin for CakePHP
Replaces regular space with a non-breaking space in places where line break should not occur as per Czech language spec
Package for manipulating colors in multiple color spaces.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
Space invoices PHP sdk
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
统计信息
- 总下载量: 125
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-18