jackal/image-merge
Composer 安装命令:
composer require jackal/image-merge
包简介
A simple PHP libraty to manipulate images
README 文档
README
A simple PHP libraty to manipulate images, it support GIF, PNG and JPG
Requirement
PHP >= 5.6 with GD support *For some additional features (for example image distortion) ImageMagick binaries are required.
Getting Started
Install library with composer
composer require jackal/image-merge
Usage
Minimal example
$imageMerge = new ImageMerge();
$imageBuilder = $imageMerge->getBuilder('/path/to/my/file.png'); #or URL, or resource, or binary content
$imageBuilder->resize(620,350)
$imageBuilder->rotate(90);
Get the image content directly to the output
[...]
echo $imageBuilder->getImage()->toPNG()->getContent();
Save image to path
[...]
$builder->getImage()->toPNG('/path/to/the/image.png');
Get image Response object (Compatible with Symgony projects)
[...]
return $imageBuilder->getImage()->toPNG()
resize
At least one parameter is required In case just one parameter is passed, it will resize maintaining the aspect ratio of the image
$imageBuilder->resize(620,null);
#or
$imageBuilder->resize(null,200);
If both parameters are passed, it could stretch the image
$imageBuilder->resize(400,200);
thumbnail
Similar to Resize but in case the aspect ratio is not respected, it will crop the image (using cropCenter)
$imageBuilder->thumbnail(400,400);
rotate
Rotate the image (counterclockwise)
$imageBuilder->rotate(180);
*In case of particular angle (30, 45, etc..) it will create blank area to fill the empty spaces
grayscale
Add a graysclae filter to the image
$imageBuilder->grayScale();
brightness
Adjusts the brightness of the image
$imageBuilder->brightness(10);
blur
Adds blur effect on the image
$imageBuilder->blur(20);
pixelate
Adds "Pixel" effect on the image
$imageBuilder->pixelate(20);
crop and cropCenter
Crop Crop the image according to the x and y coords and the output dimention passed
$point_x = 10,
$point_y = 15;
$width = 50,
$height = 50;
$imageBuilder->crop($point_x,$point_y,$width,$height);
Crop at the center of the image according to the width and height of the output image
$width = 50,
$height = 50;
$imageBuilder->cropCenter($point_x,$point_y,$width,$height);
border
It adds border to the image (fill inside the rect)
$stroke = 20;
$colorHex = '3399ff';
$builder->border($stroke,$colorHex);
Experimental features that will likely change in the future
addText
It adds text inside the image
$text = new Jackal\ImageMerge\Model\Text\Text('this is the text', Font::arial(), 12, new Color('ABCDEF'));
$builder->addText($text, 10, 20);
addSquare
It adds a square (color-filled) on the image
$builder->addSquare(10, 10, 20, 20, 'ABCDEF');
===========================================================================
Author
- Luca Giacalone (AKA JackalOne)
License
This project is licensed under the MIT License
jackal/image-merge 适用场景与选型建议
jackal/image-merge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 686 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jackal/image-merge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jackal/image-merge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 686
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-09