diff --git a/src/Intervention/Image/Image.php b/src/Intervention/Image/Image.php index e61abbc8..2819088a 100644 --- a/src/Intervention/Image/Image.php +++ b/src/Intervention/Image/Image.php @@ -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)) { diff --git a/tests/ImageTest.php b/tests/ImageTest.php index 5f5ed3d7..1dd58c2b 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -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')); } }