Returns calculated proportional width from the given height
@param integer $resized_height
@return integer
339006
public function get_prop_width($resized_height) {
        $width = intval(($this->width * $resized_height) / $this->height);
        if (!$width) $width = 1;
        return $width;
    }
625185
public function thumbizeByLimit( $width, $height )
	{
		if( !count( $this->size ) )
			throw new RuntimeException( 'No Source Image set.' );

		$ratio_s	= $this->size[0] / $this->size[1];
		$ratio_t	= $width / $height;
		if( ( $ratio_s / $ratio_t ) > 1 )
			$height	= ceil( $width / $ratio_s );
		else
			$width	= ceil( $height * $ratio_s );
		return $this->thumbize( $width, $height );
	}
250187
protected function getNewWidth($width, $height) 
    {
        if ($width > 0) {
            return $width;
        }
        
        // original height : new height = original width : X
        return $height * $this->imageInfo['width'] / $this->imageInfo['height'];
    }
446776
public static function getCalculatedSize($width, $height, $maxWidth, $maxHeight)
    {
        $widthDiffRatio = $maxWidth / $width;
        $heightDiffRatio = $maxHeight / $height;

        if ($widthDiffRatio <= $heightDiffRatio) {
            // resize based on width
            $newWidth = $maxWidth;
            $newHeight = $height * $widthDiffRatio;
        } else {
            // resize based on height
            $newWidth = $width * $heightDiffRatio;
            $newHeight = $maxHeight;
        }

        return [
            $newWidth,
            $newHeight,
        ];
    }
361189
public function resize()
    {
        $diffW = $this->originWidth / $this->targetWidth;
        $diffH = $this->originHeight / $this->targetHeight;

        if ($diffW <= 1 || $diffH <= 1) {
            $this->resizeWidth = $this->originWidth;
            $this->resizeHeight = $this->originHeight;
        } elseif ($diffW > $diffH) {
            $this->resizeHeight = $this->targetHeight;
            $this->resizeWidth = round(($this->targetHeight * $this->originWidth) / $this->originHeight);
        } else {
            $this->resizeWidth = $this->targetWidth;
            $this->resizeHeight = round(($this->targetWidth * $this->originHeight) / $this->originWidth);
        }

        return $this;
    }
980935
public function resize_max( $width, $height ) 
	{
		$new_width = $this->width;
		$new_height = $this->height;

		if ( $new_width > $width ) 
		{
			// set new with
			$new_width = $width;
			// calculate height
			$new_height = $new_width * ( $this->height / $this->width );
		}

		if ( $new_height > $height ) 
		{
			// set new height
			$new_height = $height;
			// calculate width
			$new_width = $new_height * ( $this->width / $this->height );
		}

		return $this->resize_strict( $new_width, $new_height );
	}
1081957
public function getPropWidth($height)
    {
        $ratio = (int) $height / $this->height;
        return $this->width * $ratio;
    }
490342
public function fitResize($max_width = 150, $max_height = 150, $min_width = 20, $min_height = 20) {
        $kw = $max_width / $this->width();
        $kh = $max_height / $this->height();
        if($kw > $kh) {
            $new_h = $max_height;
            $new_w = round($kh * $this->width());
        } else {
            $new_w = $max_width;
            $new_h = round($kw * $this->height());
        }
        $this->resize($new_w, $new_h);

        // Method chaining
        return $this;
    }
419610
protected function do_resize(\stdClass $src, $width, $height) {

		$src->resource->resizeImage($width, $height, \Imagick::FILTER_CATROM, 1, FALSE);
		$src->resource->convolveImage([-1, -0.8, -1, -0.8, 16, -0.8, -1, -0.8, -1]);
		
		$src->width		= $width;
		$src->height	= $height;

		return $src;
		
	}
205994
private function getHeightWidth($x, $y, $retina, $forceRatio, $size, $mode)
    {
        $newWidth = $x;
        $newHeight = $y;

        // retina x2
        if ($retina) {
            $newWidth = $x * 2;
            $newHeight = $y * 2;
        }

        // calculate height when not set
        if (!$newHeight) {
            $newHeight = $size->getHeight() / $size->getWidth() * $newWidth;
        }

        // calculate width when not set
        if (!$newWidth) {
            $newWidth = $size->getWidth() / $size->getHeight() * $newHeight;
        }

        // if image is smaller keep ratio
        // e.g. when a square image is requested (200x200) and the original image is smaller (150x100)
        //      it still returns a squared image (100x100)
        if (ImageInterface::THUMBNAIL_OUTBOUND === $mode && $forceRatio) {
            if ($newWidth > $size->getWidth()) {
                list($newHeight, $newWidth) = $this->getSizeInSameRatio(
                    $newHeight,
                    $newWidth,
                    $size->getWidth()
                );
            }

            if ($newHeight > $size->getHeight()) {
                list($newWidth, $newHeight) = $this->getSizeInSameRatio(
                    $newWidth,
                    $newHeight,
                    $size->getHeight()
                );
            }
        }

        return [$newWidth, $newHeight];
    }
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);
    }
741746
private function get_dimensions($new_width, $new_height, $option)
    {
        switch ($option) {
            case 'exact':
                $optimal_width  = $new_width;
                $optimal_height = $new_height;
                break;
            case 'portrait':
                $optimal_width  = $this->get_size_by_fixed_height($new_height);
                $optimal_height = $new_height;
                break;
            case 'landscape':
                $optimal_width  = $new_width;
                $optimal_height = $this->get_size_by_fixed_width($new_width);
                break;
            case 'auto':
                $option_array   = $this->get_size_by_auto($new_width, $new_height);
                $optimal_width  = $option_array['optimal_width'];
                $optimal_height = $option_array['optimal_height'];
                break;
            case 'fit':
                $option_array   = $this->get_size_by_fit($new_width, $new_height);
                $optimal_width  = $option_array['optimal_width'];
                $optimal_height = $option_array['optimal_height'];
                break;
            case 'crop':
                $option_array   = $this->get_optimal_crop($new_width, $new_height);
                $optimal_width  = $option_array['optimal_width'];
                $optimal_height = $option_array['optimal_height'];
                break;
        }

        return array(
            'optimal_width'  => $optimal_width,
            'optimal_height' => $optimal_height,
        );
    }
117400
public function resize($x, $y, $proportional = true)
    {
        // Check firstly values
        if ($x === null || $x > $this->width) {
            $x = $this->width;
        }

        if ($y === null || $y > $this->height) {
            $y = $this->height;
        }

        if ($proportional === true) {
            $height = $y;
            $width = round($height / $this->height * $this->width);

            if ($width < $x) {
                $width = $x;
                $height = round($width / $this->width * $this->height);
            }

        } else {
            // When no proportionality required, then use target dimensions
            $width = $x;
            $height = $y;
        }

        // Done calculating. Create a new image in memory
        $image = imagecreatetruecolor($width, $height);

        $this->preserveTransparency($image);

        imagecopyresampled($image, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);

        $this->setImage($image);

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

        return $this;
    }
649759
function proportionalSize(box, width, height) {
  if (height == null)
    height = box.height / box.width * width
  else if (width == null)
    width = box.width / box.height * height

  return {
    width:  width
  , height: height
  }
}
592281
private function get_size_by_fixed_height($new_height)
    {
        $ratio     = $this->width / $this->height;
        $new_width = $new_height * $ratio;

        return $new_width;
    }
203035
public function resize_landscape( $width, $ignore_me ) 
	{
		// calculate height
		$height = $width * ( $this->height / $this->width );

		return $this->resize_strict( $width, $height );
	}
949939
public static function get_dimensions_for_srcset_size( $resize, $srcset_size ) {
		// Get width and height for the additional src
		if ( is_array( $srcset_size ) ) {
			$width  = $srcset_size[0];
			$height = isset( $srcset_size[1] ) ? $srcset_size[1] : 0;
		} else {
			$width  = (int) round( $resize[0] * $srcset_size );
			$height = isset( $resize[1] ) ? (int) round( $resize[1] * $srcset_size ) : 0;
		}

		return array( $width, $height );
	}