Resize the image to fill the new size. This will crop your image.

@param int 		$width
@param int 		$height
@return self

@thanks to: http://stackoverflow.com/questions/1855996/crop-image-in-php
508613
public function resize_fill( $width, $height ) 
	{
		$original_aspect = $this->width / $this->height;
		$thumb_aspect = $width / $height;

		if ( $original_aspect >= $thumb_aspect )
		{
		   $new_height = $height;
		   $new_width = $this->width / ($this->height / $height);
		}
		else
		{
		   $new_width = $width;
		   $new_height = $this->height / ($this->width / $width);
		}

		$x = 0 - ( $new_width - $width ) / 2;
		$y = 0 - ( $new_height - $height ) / 2;

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

		// overwrite the image context 
		$this->image_context = $result;

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

		// return self
		return $this;
	}
327559
public function runCropResize(Image $image, $width, $height)
    {
        list($resize_width, $resize_height) = $this->resolveCropResizeDimensions($image, $width, $height);

        $zoom = $this->getCrop()[2];

        $image->resize($resize_width * $zoom, $resize_height * $zoom, function ($constraint) {
            $constraint->aspectRatio();
        });

        list($offset_x, $offset_y) = $this->resolveCropOffset($image, $width, $height);

        return $image->crop($width, $height, $offset_x, $offset_y);
    }
946516
protected function resizeCrop($file, $width, $height)
  	{
		$image = $this->imagine->open($file->getRealPath());
		list($optimalWidth, $optimalHeight) = $this->getOptimalCrop($image->getSize(), $width, $height);

    	// Find center - this will be used for the crop
		$centerX = ($optimalWidth / 2) - ($width / 2);
    	$centerY = ($optimalHeight / 2) - ($height / 2);

		return $image->resize(new Box($optimalWidth, $optimalHeight))
			->crop(new Point($centerX, $centerY), new Box($width, $height));
	}
769740
public function scale($width, $height) {
		$image = new Image();
		$image->create($width, $height, $this->type);

		$result = $image->copyFromWithReSampling($this);

        $this->close();

		$this->image = $image->image;
		$image->setEmptyImage();
		$this->width = $width;
		$this->height = $height;
		return $result;
	}
539068
public function resize_fit($width, $height) {
        if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height)))
            return true;
        if (!$width || (($height / $width) < ($this->height / $this->width)))
            $width = intval(($this->width * $height) / $this->height);
        elseif (!$height || (($width / $height) < ($this->width / $this->height)))
            $height = intval(($this->height * $width) / $this->width);
        if (!$width) $width = 1;
        if (!$height) $height = 1;
        return $this->resize($width, $height);
    }
1051075
public function resize($width, $height)
    {
        $newImage = imagecreatetruecolor($width, $height);

        $this->strategy->handleTransparency($newImage, $this->image);

        // Now resample the image
        imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());

        // And allocate to $this
        $this->image = $newImage;
    }
983752
public function Fill($width, $height)
    {
        $width = $this->castDimension($width, 'Width');
        $height = $this->castDimension($height, 'Height');
        $variant = $this->variantName(__FUNCTION__, $width, $height);
        return $this->manipulateImage($variant, function (Image_Backend $backend) use ($width, $height) {
            if ($backend->getWidth() === $width && $backend->getHeight() === $height) {
                return $this;
            }
            return $backend->croppedResize($width, $height);
        });
    }
41485
public function do_crop($width, $height, $offsetX = 0, $offsetY = 0)
    {
        if (version_compare(PHP_VERSION, '5.5.0') < 0) {
            $image = imagecreatetruecolor($width, $height);
            imagealphablending($image, false);
            imagesavealpha($image, true);
            imagecopy($image, $this->_image, 0, 0, $offsetX, $offsetY, $width, $height);
        } else {
            $rect = ['x' => $offsetX, 'y' => $offsetY, 'width' => $width, 'height' => $height];
            $image = imagecrop($this->_image, $rect);
        }

        imagedestroy($this->_image);
        $this->_image = $image;
        $this->_width = imagesx($image);
        $this->_height = imagesy($image);

        return $this;
    }
936540
public function resize(int $width = 0, int $height = 0)
    {
        if (!$width && !$height) {
            throw new ImageException('You must supply at least one dimension');
        }
        $iw = $this->info[0];
        $ih = $this->info[1];
        if (!$height || !$width) {
            if (!$width) {
                $width  = $height / $ih * $iw;
            }
            if (!$height) {
                $height = $width  / $iw * $ih;
            }
        }
        $di = imagecreatetruecolor($width, $height);
        imagecopyresized($di, $this->data, 0, 0, 0, 0, $width, $height, $iw, $ih);
        $this->data = $di;
    }
564521
public function resize($width, $height) {
        if (!$width) $width = 1;
        if (!$height) $height = 1;
        return (
            (false !== ($img = new gd(array($width, $height)))) &&
            $img->imagecopyresampled($this) &&
            (false !== ($this->image = $img->get_image())) &&
            (false !== ($this->width = $img->get_width())) &&
            (false !== ($this->height = $img->get_height()))
        );
    }
345545
public function crop($width = null, $height = null)
    {
        //get the source width and height
        $orgWidth = imagesx($this->resource);
        $orgHeight = imagesy($this->resource);

        //set the width if none is defined
        if (is_null($width)) {
            $width = $orgWidth;
        }

        //set the height if none is defined
        if (is_null($height)) {
            $height = $orgHeight;
        }

        //if the width and height are the same as the originals
        if ($width == $orgWidth && $height == $orgHeight) {
            //there's no need to process
            return $this;
        }

        //if we are here then we do need to crop
        //create the new resource with the width and height
        $crop = imagecreatetruecolor($width, $height);

        //set some defaults
        $xPosition = 0;
        $yPosition = 0;

        //if the width is greater than the original width
        //or if the height is greater than the original height
        if ($width > $orgWidth || $height > $orgHeight) {
            //save the destination width and height
            //because they will change here
            $newWidth = $width;
            $newHeight = $height;

            //if the desired height is larger than the desired width
            if ($height > $width) {
                //and adjust the height instead
                $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
                //if the aspect height is bigger than the desired height
                if ($newHeight > $height) {
                    //set it back to the desired height
                    $height = $newHeight;
                    //and adjust the width instead
                    $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
                    //now because of the way GD renders we need to find the ratio of desired
                    //height if it was brought down to the original height
                    $rWidth = $this->getWidthAspectRatio($newWidth, $newHeight, $orgHeight);
                    //set the x Position of the source to the center of the
                    //original width image width minus half the rWidth width
                    $xPosition = ($orgWidth / 2) - ($rWidth / 2);
                } else {
                    //now because of the way GD renders we need to find the ratio of desired
                    //height if it was brought down to the original height
                    $rHeight = $this->getHeightAspectRatio($newWidth, $newHeight, $orgWidth);
                    //set the y Position of the source to the center of the
                    //new sized image height minus half the desired height
                    $yPosition = ($orgHeight / 2) - ($rHeight / 2) ;
                }
            //if the desired height is smaller than the desired width
            } else {
                //get the width aspect ratio
                $width = $this->getWidthAspectRatio($orgWidth, $orgHeight, $height);
                //if the aspect height is bigger than the desired height
                if ($newWidth > $width) {
                    //set it back to the desired height
                    $width = $newWidth;
                    //and adjust the width instead
                    $height = $this->getHeightAspectRatio($orgWidth, $orgHeight, $width);
                    //now because of the way GD renders we need to find the ratio of desired
                    //height if it was brought down to the original height
                    $rHeight = $this->getHeightAspectRatio($newWidth, $newHeight, $orgWidth);
                    //set the y Position of the source to the center of the
                    //new sized image height minus half the desired height
                    $yPosition = ($orgHeight / 2) - ($rHeight / 2) ;
                } else {
                    //now because of the way GD renders we need to find the ratio of desired
                    //height if it was brought down to the original height
                    $rWidth = $this->getWidthAspectRatio($newWidth, $newHeight, $orgHeight);
                    //set the x Position of the source to the center of the
                    //original width image width minus half the rWidth width
                    $xPosition = ($orgWidth / 2) - ($rWidth / 2);
                }
            }
        } else {
            //if the width is less than the original width
            if ($width < $orgWidth) {
                //set the x Position of the source to the center of the
                //original image width minus half the desired width
                $xPosition = ($orgWidth / 2) - ($width / 2);
                //set the destination width to be the original width
                $width = $orgWidth;
            }

            //if the height is less than the original height
            if ($height < $orgHeight) {
                //set the y Position of the source to the center of the
                //original image height minus half the desired height
                $yPosition = ($orgHeight / 2) - ($height / 2);
                //set the destination height to be the original height
                $height = $orgHeight;
            }
        }

        //render the image
        imagecopyresampled($crop, $this->resource, 0, 0, $xPosition, $yPosition, $width, $height, $orgWidth, $orgHeight);

        //destroy the original resource
        imagedestroy($this->resource);

        //assign the new resource
        $this->resource = $crop;

        return $this;
    }
449532
public function resizeH($height)
    {
        $tmpWidth = $height / $this->height * $this->width;
        $this->resize((int)$tmpWidth, (int)$height);
    }
4212
protected function resizeCrop(ImageInterface $image, $width, $height)
    {
        list($optimalWidth, $optimalHeight) = $this->getOptimalCrop($image->getSize(), $width, $height);

        // Find center - this will be used for the crop
        $centerX = ($optimalWidth / 2) - ($width / 2);
        $centerY = ($optimalHeight / 2) - ($height / 2);

        return $image->resize(new Box($optimalWidth, $optimalHeight))
            ->crop(new Point($centerX, $centerY), new Box($width, $height));
    }
1341255
protected function resizeImage($path, $width, $height)
    {
        $this->images->open('Gd',$path);
        $this->images->resize($width, $height);
    }
709005
public function thumbnail($width, $height = null)
    {
        if (!isset($height)) {
            $height = $width;
        }

        if (($height / $width) > ($this->height / $this->width)) {
            $this->fitToHeight($height);
        } else {
            $this->fitToWidth($width);
        }

        $left = floor(($this->width / 2) - ($width / 2));
        $top = floor(($this->height / 2) - ($height / 2));

        return $this->crop($left, $top, $width + $left, $height + $top);
    }
809368
final public function crop($x = 0, $y = 0, $width = null, $height = null)
	{
		$this->_image_handle = imagecrop(
			$this->_image_handle,
			array_merge(
				array(
					'x' => 0,
					'y' => 0,
					'width' => $this->imageWidth(),
					'height' => $this->imageHeight()
				),
				array_filter(
					array_combine(
						array('x', 'y', 'width', 'height'),
						array($x, $y, $width, $height)
					)
				)
			)
		);

		return $this;
	}
550615
public function cropAndResizeFromCenter($width, $height)
        {
            $this->resizeOut($width, $height);
            $this->cropFromCenter($width, $height);

            return $this;
        }