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:
@@ -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)) {
|
||||
|
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user