protected function createCrop($crop, $image)
	{
		if (!empty($crop['cropped_field'])) {
			$save_path = $this->getUploadPath($crop['cropped_field']);
		} else {
			$save_path = $this->getUploadPath($this->attribute);
		}

		$sizes = explode('-', $crop['value']);

		$real_size = $image->getSize();

		foreach ($sizes as $ind => $cr) {
			$sizes[$ind] = round($sizes[$ind]*($ind%2 == 0 ? $real_size->getWidth() : $real_size->getHeight())/100);
		}

		$crop_image = $image->crop(new Point($sizes[0], $sizes[1]), new Box($sizes[2]-$sizes[0], $sizes[3]-$sizes[1]));

		if (!empty($crop['crop_width']))
			$crop_image = $crop_image->resize(new Box($crop['crop_width'], $crop['crop_width'] / $crop['ratio']));

		$crop_image->save($save_path, isset($crop['save_options']) ? $crop['save_options'] : $this->save_options);
	}
protected function createCrop($crop, $image)
	{
		if (!empty($crop['cropped_field'])) {
			$save_path = $this->getUploadPath($crop['cropped_field']);
		} else {
			$save_path = $this->getUploadPath($this->attribute);
		}

		$sizes = explode('-', $crop['value']);

		$real_size = $image->getSize();

		foreach ($sizes as $ind => $cr) {
			$sizes[$ind] = round($sizes[$ind]*($ind%2 == 0 ? $real_size->getWidth() : $real_size->getHeight())/100);
		}

		$crop_image = $image->crop(new Point($sizes[0], $sizes[1]), new Box($sizes[2]-$sizes[0], $sizes[3]-$sizes[1]));

		if (!empty($crop['crop_width']))
			$crop_image = $crop_image->resize(new Box($crop['crop_width'], $crop['crop_width'] / $crop['ratio']));

		$crop_image->save($save_path, isset($crop['save_options']) ? $crop['save_options'] : $this->save_options);
	}
protected function createCrop ( $ crop , $ image ) { if ( ! empty ( $ crop [ 'cropped_field' ] ) ) { $ save_path = $ this -> getUploadPath ( $ crop [ 'cropped_field' ] ) ; } else { $ save_path = $ this -> getUploadPath ( $ this -> attribute ) ; } $ sizes = explode ( '-' , $ crop [ 'value' ] ) ; $ real_size = $ image -> getSize ( ) ; foreach ( $ sizes as $ ind => $ cr ) { $ sizes [ $ ind ] = round ( $ sizes [ $ ind ] * ( $ ind % 2 == 0 ? $ real_size -> getWidth ( ) : $ real_size -> getHeight ( ) ) / 100 ) ; } $ crop_image = $ image -> crop ( new Point ( $ sizes [ 0 ] , $ sizes [ 1 ] ) , new Box ( $ sizes [ 2 ] - $ sizes [ 0 ] , $ sizes [ 3 ] - $ sizes [ 1 ] ) ) ; if ( ! empty ( $ crop [ 'crop_width' ] ) ) $ crop_image = $ crop_image -> resize ( new Box ( $ crop [ 'crop_width' ] , $ crop [ 'crop_width' ] / $ crop [ 'ratio' ] ) ) ; $ crop_image -> save ( $ save_path , isset ( $ crop [ 'save_options' ] ) ? $ crop [ 'save_options' ] : $ this -> save_options ) ; }
this method crops the image
@param Array $crop crop config
@param \Imagine\Gd\Image $image
this method crops the image