mirror of
https://github.com/Intervention/image.git
synced 2025-08-22 05:22:50 +02:00
added possibility to define trim borders as strings
This commit is contained in:
@@ -711,7 +711,13 @@ class Image
|
|||||||
{
|
{
|
||||||
// default values
|
// default values
|
||||||
$checkTransparency = false;
|
$checkTransparency = false;
|
||||||
$away = is_array($away) ? $away : array('top', 'right', 'bottom', 'left');
|
|
||||||
|
// define borders to trim away
|
||||||
|
if (is_null($away)) {
|
||||||
|
$away = array('top', 'right', 'bottom', 'left');
|
||||||
|
} elseif (is_string($away)) {
|
||||||
|
$away = array($away);
|
||||||
|
}
|
||||||
|
|
||||||
// define base color position
|
// define base color position
|
||||||
switch (strtolower($base)) {
|
switch (strtolower($base)) {
|
||||||
|
@@ -1702,5 +1702,11 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$this->assertEquals($img->width, 16);
|
$this->assertEquals($img->width, 16);
|
||||||
$this->assertEquals($img->height, 16);
|
$this->assertEquals($img->height, 16);
|
||||||
|
|
||||||
|
$img = Image::make('public/trim.png');
|
||||||
|
$img->trim('top-left', 'right');
|
||||||
|
$this->assertEquals($img->width, 39);
|
||||||
|
$this->assertEquals($img->height, 50);
|
||||||
|
$this->assertEquals('#00aef0', $img->pickColor(6, 6, 'hex'));
|
||||||
|
$this->assertEquals('#f6a609', $img->pickColor(11, 25, 'hex'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user