I upload 500*500

and resize to 300*400, then i get this:

It it seems that resizeTo just resize my picture with newWidth and newHeight;
is there any function that resizes and crops my picture, please?
or do i need something like
	
	
	
		
				
			
and resize to 300*400, then i get this:

It it seems that resizeTo just resize my picture with newWidth and newHeight;
is there any function that resizes and crops my picture, please?
or do i need something like
		Code:
	
	    if ($width < $image->getWidth())
    {
    $x = ($image->getWidth() / 2) - ($width / 2);
    }
    if ($height < $image->getHeight())
    {
    $y = ($image->getHeight() / 2) - ($height / 2);
    }
    $image->resizeAndCrop($width, $height, $x, $y);