rych / cropbuddy
使用 PHP 智能裁剪图像
dev-master
2014-04-10 01:21 UTC
Requires
- php: >=5.3.0
- ext-imagick: *
This package is auto-updated.
Last update: 2024-09-23 11:29:46 UTC
README
这是作为更大项目的一部分而快速编写的一个项目。这个库接受一个 Imagick 对象,并使用给定的裁剪策略裁剪图像。
它是如何工作的?
CropBuddy 直接修改您的 Imagick 对象。它可以调整大小和/或裁剪图像到指定的尺寸。
包含的策略有
- CenterStrategy - 默认,从图像中心裁剪
- EntropyStrategy - 裁剪到图像最有兴趣的部分(我对选定的部分有多有趣不做保证)
用法
<?php $strategy = new \Rych\CropBuddy\Strategy\EntropyStrategy(); $cb = new \Rych\CropBuddy\CropBuddy($myImagickObject, $strategy); // Resize the image to either a height or width of 150px // A 600x300 image will end up at 300x150 $cb->resize(150, 150); // Square the image to 150x150 $cb->crop(150, 150);
安装
Composer
composer require rych/cropbuddy:dev-master@dev
待办事项
添加更多策略并编写单元测试。