1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-20 04:31:24 +02:00

added possibility to define trim borders as strings

This commit is contained in:
Oliver Vogel
2013-11-08 15:39:03 +01:00
parent 4a863c38bb
commit 199b278c63
2 changed files with 14 additions and 2 deletions

View File

@@ -711,7 +711,13 @@ class Image
{
// default values
$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
switch (strtolower($base)) {

View File

@@ -1701,6 +1701,12 @@ class ImageTest extends PHPUnit_Framework_Testcase
$img->trim(); // trim nothing because image is just one color
$this->assertEquals($img->width, 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'));
}
}