1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-26 15:24:37 +02:00

Update src/Intervention/Image/Image.php

Added crop function: Image::crop($src_x , $src_y , $src_w , $src_h)
This commit is contained in:
David D.
2013-02-27 14:40:51 -07:00
parent aa4f78b92f
commit 207b2b12fa

View File

@@ -315,6 +315,23 @@ class Image
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
*