diff --git a/src/Intervention/Image/Image.php b/src/Intervention/Image/Image.php index 921ef551..fa08a1b4 100644 --- a/src/Intervention/Image/Image.php +++ b/src/Intervention/Image/Image.php @@ -314,6 +314,23 @@ class Image $height = array_key_exists('height', $dimensions) ? intval($dimensions['height']) : null; return $this->resize($width, $height, true); } + + /** + * Crop an image + * + * @param integer $src_x + * @param integer $src_y + * @param integer $src_w + * @param integer $src_h + * @return Image + */ + public function crop($src_x , $src_y , $src_w , $src_h) + { + if (is_null($src_x) || is_null($src_y) || is_null($src_w) || is_null($src_h)) { + throw new Exception('x, y, width and height needs to be defined'); + } + $this->modify(0, 0, $src_x , $src_y, $src_w, $src_h, $src_w, $src_h); + } /** * Cut out a detail of the image in given ratio and resize to output size