yii\imagine\BaseImage::resize PHP Method

resize() public static method

If one of the dimensions is set to null, another one is calculated automatically based on aspect ratio of original image. If both of the dimensions are set then new dimensions are calculated so that image keeps aspect ratio. You can set $keepAspectRatio to false if you want to force fixed width and height.
Since: 2.1.1
public static resize ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, boolean $keepAspectRatio = true, boolean $allowUpscaling = false ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$width integer the width in pixels
$height integer the height in pixels
$keepAspectRatio boolean should the image keep aspect ratio
$allowUpscaling boolean should the image be upscaled if needed
return Imagine\Image\ImageInterface
    public static function resize($image, $width, $height, $keepAspectRatio = true, $allowUpscaling = false)
    {
        $img = self::ensureImageInterfaceInstance($image)->copy();
        /** @var BoxInterface $sourceBox */
        $sourceBox = $img->getSize();
        $destinationBox = static::getBox($sourceBox, $width, $height, $keepAspectRatio);
        if ($allowUpscaling === false && self::isUpscaling($sourceBox, $destinationBox)) {
            return $img;
        }
        return $img->resize($destinationBox);
    }