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:
@@ -314,6 +314,23 @@ class Image
|
|||||||
$height = array_key_exists('height', $dimensions) ? intval($dimensions['height']) : null;
|
$height = array_key_exists('height', $dimensions) ? intval($dimensions['height']) : null;
|
||||||
return $this->resize($width, $height, true);
|
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
|
* Cut out a detail of the image in given ratio and resize to output size
|
||||||
|
Reference in New Issue
Block a user