ihorhnatchuk/laravel-image-thumbnail
Composer 安装命令:
composer require ihorhnatchuk/laravel-image-thumbnail
包简介
Image manipulation library for Laravel 8 based on Imagine and inspired by Croppa for easy url based manipulation
README 文档
README
Laravel Image is an image manipulation package for Laravel 4 and 5 based on the PHP Imagine library. It is inspired by Croppa as it can use specially formatted urls to do the manipulations. It supports basic image manipulations such as resize, crop, rotation and flip. It also supports effects such as negative, grayscale, gamma, colorize and blur. You can also define custom filters for greater flexibility.
The main difference between this package and other image manipulation libraries is that you can use parameters directly in the url to manipulate the image. A manipulated version of the image is then saved in the same path as the original image, creating a static version of the file and bypassing PHP for all future requests.
For example, if you have an image at this URL:
/uploads/photo.jpg
To create a 300x300 version of this image in black and white, you use the URL:
/uploads/photo-image(300x300-crop-grayscale).jpg
To help you generate the URL to an image, you can use the Thumbnail::url() method
Thumbnail::url('/uploads/photo.jpg',300,300,array('crop','grayscale'));
or
<img src="<?=Thumbnail::url('/uploads/photo.jpg',300,300,array('crop','grayscale'))?>" />
Alternatively, you can programmatically manipulate images using the Thumbnail::make() method. It supports all the same options as the Thumbnail::url() method.
Thumbnail::make('/uploads/photo.jpg',array( 'width' => 300, 'height' => 300, 'grayscale' => true ))->save('/path/to/the/thumbnail.jpg');
or use directly the Imagine library
$thumbnail = Thumbnail::open('/uploads/photo.jpg') ->thumbnail(new Imagine\Image\Box(300,300)); $thumbnail->effects()->grayscale(); $thumbnail->save('/path/to/the/thumbnail.jpg');
Features
This package use Imagine for image manipulation. Imagine is compatible with GD2, Imagick, Gmagick and supports a lot of features.
This package also provides some common filters ready to use (more on this):
- Resize
- Crop (with position)
- Rotation
- Black and white
- Invert
- Gamma
- Blur
- Colorization
- Interlace
Version Compatibility
| Laravel | Image |
|---|---|
| 4.2.x | 0.1.x |
| 5.0.x | 0.2.x |
| 5.1.x | 0.3.x |
| 5.2.x | 0.3.x |
| 8.2.x | 0.3.x |
Installation
Dependencies:
Server Requirements:
Installation:
1- Require the package via Composer in your composer.json.
{
"require": {
"folklore/image": "0.3.*"
}
}
2- Run Composer to install or update the new requirement.
$ composer install
or
$ composer update
3- Add the service provider to your app/config/app.php file
'Folklore\Image\ImageServiceProvider',
4- Add the facade to your app/config/app.php file
'Image' => 'Folklore\Image\Facades\Image',
5- Publish the configuration file and public files
$ php artisan vendor:publish --provider="Folklore\Image\ImageServiceProvider"
6- Review the configuration file
app/config/image.php
Documentation
Roadmap
Here are some features we would like to add in the future. Feel free to collaborate and improve this library.
- More built-in filters such as Brightness and Contrast
- More configuration when serving images
- Artisan command to manipulate images
- Support for batch operations on multiple files
ihorhnatchuk/laravel-image-thumbnail 适用场景与选型建议
ihorhnatchuk/laravel-image-thumbnail 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.87k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「thumbnail」 「imagine」 「gd」 「imagick」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ihorhnatchuk/laravel-image-thumbnail 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ihorhnatchuk/laravel-image-thumbnail 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ihorhnatchuk/laravel-image-thumbnail 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides integration between LiipImagineBundle and JMSSerializerBundle.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
A PHP library for fetching thumbnails from a URL
Image manipulation using Imagine and Twig Filters.
Image Imagine generator for Nette Framework
统计信息
- 总下载量: 2.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-29