gwa/gw-image-editor
Composer 安装命令:
composer require gwa/gw-image-editor
包简介
Simple PHP image manipulation library
README 文档
README
A PHP image editor library that uses the bundled GD library.
Provides a simple and intuitive interface for typical editing, cropping, resizing and filtering actions on existing images.
Typical use cases:
- Scaling and cropping uploaded images to within constraints
- Creating different sized versions of an image
- Adding watermarks
Installation
Install through composer:
composer require gwa/gw-image-editor
Usage
use Gwa\Image\ImageEditor; // create an editor using an existing image $editor = new ImageEditor('path/to/image.png'); // resize image to within 640 x 480 px, maintaining aspect ratio $editor->resizeToWithin(640, 480) ->save(); // resize image to exactly 640 x 480 px, cropping any overhang $editor->resizeTo(640, 480) ->save(); // resize image to exactly 640px width, preserving aspect ratio $editor->resizeTo(640) ->save(); // resize image to exactly 480px height, preserving aspect ratio $editor->resizeTo(null, 480) ->save(); // crop the image: x, y, width, height $editor->crop(10, 10, 100, 100) ->save(); // methods can be chained // - create and save medium image with max width and height of 500px // - create and save thumbnail image with exact dimensions of 100px x 100px $editor = new ImageEditor('path/to/original.jpg'); $editor->resizeToWithin(500, 500) ->saveAs('path/to/medium.jpg') ->resizeTo(100, 100) ->saveAs('path/to/thumbnail.jpg') ->saveAs('path/to/thumbnail.png', IMAGETYPE_PNG); // another image can be "pasted" in (e.g. a watermark) // - paste watermark into bottom right corner $editor = new ImageEditor('path/to/original.jpg'); $iw = $editor->getWidth(); $ih = $editor->getHeight(); $watermark = new ImageEditor('path/to/watermark.png'); $ww = $watermark->getWidth(); $wh = $watermark->getHeight(); $padding = 10; $editor->pasteImage($watermark, $iw - $ww - $padding, $ih - $wh - $padding) ->saveAs('path/to/watermarked.jpg'); // there are also filter methods available $editor = new ImageEditor('path/to/original.jpg'); $editor->grayscale() ->coloroverlay(0, 0, 0, 50) // 50% black overlay ->colorize(255, 0, 0, 0) // rgba
Tests
PHPUnit
$ ./vendor/bin/phpunit -c tests/phpunit.xml --coverage-html=tests/_report tests
Code style (PSR-2)
$ ./vendor/bin/phpcs --standard=PSR2 src
gwa/gw-image-editor 适用场景与选型建议
gwa/gw-image-editor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.96k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gwa/gw-image-editor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gwa/gw-image-editor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-06-02