Fit to height (proportionally resize to specified height)

@param $height
@return Image
761502
public function fit_to_height($height)
    {
        $aspect_ratio = $this->height / $this->width;
        $width = $height / $aspect_ratio;

        return $this->resize($width, $height);
    }
978462
public function thumbnail($width = 50, $height = 50, $fit = 'outbound') {
        return $this->addTransformation(
            sprintf('thumbnail:width=%d,height=%s,fit=%s', (int) $width, (int) $height, $fit)
        );
    }
426849
public function setHeight(int $height) : AbstractResize
    {
        if ($height < 1) {
            throw new \InvalidArgumentException(Helper::ERROR_HEIGHT_INVALID);
        }

        $this->canvas['height'] = $height;

        return $this;
    }
398815
public function resize($width, $height) {
        if ($width && $height) $this->thumb->resize($width, $height);
        else if (!$width) $this->thumb->resize(99999, $height);
        else if (!$height) $this->thumb->resize($width, 99999);
        return $this;
    }
1203319
static public function create($width, $height) {
		$image = imagecreatetruecolor($width, $height);
		imagealphablending($image, false);
		imagesavealpha($image, true);
		return new self($image);
	}
1251185
public function resize($width, $height)
    {
        $new = imagecreatetruecolor($width, $height);

        if (empty($new)) {
            throw new UnexpectedValueException('Failed to create an image identifier');
        }

        if ($this->format === 'gif') {

            $transparent_index = imagecolortransparent($this->image);
            $palletsize = imagecolorstotal($this->image);

            if ($transparent_index >= 0 && $transparent_index < $palletsize) {
                $transparent_color = imagecolorsforindex($this->image, $transparent_index);
                $transparent_index = imagecolorallocate($new, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
                imagefill($new, 0, 0, $transparent_index);
                imagecolortransparent($new, $transparent_index);
            }
        } else {
            imagealphablending($new, false);
            imagesavealpha($new, true);
        }

        if (!imagecopyresampled($new, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height)) {
            throw new UnexpectedValueException('Failed to copy and resize part of an image with resampling');
        }

        $this->image = $new;
        $this->width = $width;
        $this->height = $height;

        return $this;
    }
214802
public function fit_to_width($width)
    {
        $aspect_ratio = $this->height / $this->width;
        $height = $width * $aspect_ratio;

        return $this->resize($width, $height);
    }
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;
	}
1054838
public function resize($width = 0, $height = 0) 
    {
        if ($width != 0 || $height != 0) {
            $width = $this->getNewWidth($width, $height);
            $height = $this->getNewHeight($width, $height);
        } else {
            $width = $this->imageInfo['width'];
            $height = $this->imageInfo['height'];
        }

        $this->destImageWidth = $width;
        $this->destImageHeight = $height;
        
        return $this;
    }
825403
public function setSize($width = null, $height = null) 
	{
		if(null === $height && null !== $width) {
			if($width > $this->imageInfo['width']) {
				$width = $this->imageInfo['width'];
			}
			// $width : $this->imageInfo['width'] = $height : $this->imageInfo['height']
			$height = (int) ($width * $this->imageInfo['height'] / $this->imageInfo['width']);
		}
		
		if(null === $width && null !== $height) {
			if($height > $this->imageInfo['height']) {
				$height = $this->imageInfo['height'];
			}
			// $width : $this->imageInfo['width'] = $height : $this->imageInfo['height']
			$width = (int) ($height * $this->imageInfo['width'] / $this->imageInfo['height']);
		}
	
		$this->width = $width;
		$this->height = $height;
		
		return $this;
	}
800986
public function resize($width, $height) {
		$image = imagecreatetruecolor($width, $height);
		imagealphablending($image, false);
		imagesavealpha($image, true);
		imagecopyresampled($image, $this->_image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
		imagedestroy($this->_image);
		$this->_image = $image;
		return $this;
	}
716267
public function resize(Int $width, Int $height) : Thumb
    {
        $this->sets['rewidth']  = $width;
        $this->sets['reheight'] = $height;

        return $this;
    }
1282342
public function runContainResize(Image $image, $width, $height)
    {
        return $image->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
        });
    }
306491
public function resizeToHeight($height, $allow_enlarge = false)
    {
        $ratio = $height / $this->getSourceHeight();
        $width = $this->getSourceWidth() * $ratio;

        $this->resize($width, $height, $allow_enlarge);

        return $this;
    }
1004578
public function resize($width = null, $height = null) {
        $params = array();

        if ($width) {
            $params[] = 'width=' . (int) $width;
        }

        if ($height) {
            $params[] = 'height=' . (int) $height;
        }

        if (!$params) {
            throw new InvalidArgumentException('width and/or height must be specified');
        }

        return $this->addTransformation(sprintf('resize:%s', implode(',', $params)));
    }
997990
public function getNewDimensions($width, $height)
    {
        if(!$this->resizeSmaller && $this->height >= $height && $this->width >= $width)
        {
            return parent::getNewDimensions($width, $height);
        }

        if(in_array($this->resizeMode, array($this::MODE_CROP, $this::MODE_STRETCH, $this::MODE_EXACT)))
        {
            return parent::getNewDimensions($this->width, $this->height);
        }
        elseif($this->resizeMode === $this::MODE_FILL)
        {
            $ratioH = $this->height / $height;
            $ratioW = $this->width / $width;

            $widthFill  = max($width * $ratioH, $width * $ratioW);
            $heightFill = max($height * $ratioH, $height * $ratioW);
            $ratio = max($widthFill / $width, $heightFill / $height);

            return parent::getNewDimensions(round($width * $ratio), round($height * $ratio));
        }
        else
        {
            $pictureWidth  = $this->width;
            $pictureHeight = $this->height;

            if($width > $pictureWidth || $height > $pictureHeight)
            {
                if($width > $height)
                {
                    $pictureHeight = floor(($height / $width) * $pictureWidth);
                }
                elseif($width < $height)
                {
                    $pictureWidth = floor(($width / $height) * $pictureHeight);
                }
            }

            return parent::getNewDimensions($pictureWidth, $pictureHeight);
        }
    }
646567
public function getProsize(Int $width = 0, Int $height = 0)
    {
        if( ! isset($this->sets['filePath']) )
        {
            return false;
        }

        return $this->image->getProsize($this->sets['filePath'], $width, $height);
    }