src/classes/CCImage.php
public function crop( $x, $y, $width, $height )
	{
		// check for auto
		if ( $x == 'center' || $x == 'auto' )
		{
			$x = ( $this->width / 2 ) - ( $width / 2 );
		}

		if ( $y == 'middle' || $y == 'auto' )
		{
			$y = ( $this->height / 2 ) - ( $height / 2 );
		}

		$result = imagecreatetruecolor( $width, $height );  
		ImageCopyResampled( $result, $this->image_context, 0, 0, $x, $y, $width, $height, $width, $height );

		$this->image_context = $result;

		// update properties
		$this->reload_context_info();

		// return self
		return $this;
	}
public function crop( $x, $y, $width, $height )
	{
		// check for auto
		if ( $x == 'center' || $x == 'auto' )
		{
			$x = ( $this->width / 2 ) - ( $width / 2 );
		}

		if ( $y == 'middle' || $y == 'auto' )
		{
			$y = ( $this->height / 2 ) - ( $height / 2 );
		}

		$result = imagecreatetruecolor( $width, $height );  
		ImageCopyResampled( $result, $this->image_context, 0, 0, $x, $y, $width, $height, $width, $height );

		$this->image_context = $result;

		// update properties
		$this->reload_context_info();

		// return self
		return $this;
	}
public function crop ( $ x , $ y , $ width , $ height ) { // check for auto if ( $ x == 'center' || $ x == 'auto' ) { $ x = ( $ this -> width / 2 ) - ( $ width / 2 ) ; } if ( $ y == 'middle' || $ y == 'auto' ) { $ y = ( $ this -> height / 2 ) - ( $ height / 2 ) ; } $ result = imagecreatetruecolor ( $ width , $ height ) ; ImageCopyResampled ( $ result , $ this -> image_context , 0 , 0 , $ x , $ y , $ width , $ height , $ width , $ height ) ; $ this -> image_context = $ result ; // update properties $ this -> reload_context_info ( ) ; // return self return $ this ; }
Crop the current image

This is a simplefied crop.

@param int 		$x
@param int 		$y
@param int		$width
@param int 		$height

@return self
Crop the current image