XF 2.2 $image->ResizeTo

Robert9

Well-known member
I upload 500*500

original.jpg

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

result.jpg


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);
 
Top Bottom