mirror of
https://github.com/Intervention/image.git
synced 2025-08-13 17:34:04 +02:00
Added feather parameter to trim()
This commit is contained in:
@@ -727,9 +727,10 @@ class Image
|
|||||||
* @param string $base Position of the color to trim away
|
* @param string $base Position of the color to trim away
|
||||||
* @param array $away Borders to trim away
|
* @param array $away Borders to trim away
|
||||||
* @param int $tolerance Tolerance of color comparison
|
* @param int $tolerance Tolerance of color comparison
|
||||||
|
* @param int $feather Amount of pixels outside (when positive) or inside (when negative) of the strict limit of the matched color
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
public function trim($base = null, $away = null, $tolerance = null)
|
public function trim($base = null, $away = null, $tolerance = null, $feather = 0)
|
||||||
{
|
{
|
||||||
// default values
|
// default values
|
||||||
$checkTransparency = false;
|
$checkTransparency = false;
|
||||||
@@ -866,8 +867,8 @@ class Image
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim parts of image
|
// trim parts of image, taking a possible feathering range into account
|
||||||
$this->modify(0, 0, $top_x, $top_y, ($bottom_x-$top_x), ($bottom_y-$top_y), ($bottom_x-$top_x), ($bottom_y-$top_y));
|
$this->modify(0, 0, max(0, $top_x - $feather), max(0, $top_y - $feather), ($bottom_x-$top_x) + (2 * $feather), ($bottom_y-$top_y) + (2 * $feather), ($bottom_x-$top_x) + (2 * $feather), ($bottom_y-$top_y) + (2 * $feather));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user