JBZoo\Image\Image::fitToHeight PHP Method

fitToHeight() public method

Fit to height (proportionally resize to specified height)
public fitToHeight ( integer $height )
$height integer
    public function fitToHeight($height)
    {
        $height = VarFilter::int($height);
        $width = $height / ($this->_height / $this->_width);
        return $this->resize($width, $height);
    }

Usage Example

Ejemplo n.º 1
0
 public function uploadImage($fieldName = "upload", $folder = "upload/", $width = null, $height = null)
 {
     $output = $this->upload($fieldName, $folder);
     $path = $output["url"];
     $img = new Image($path);
     if ($width == null && $height == null) {
         return $output;
     } else {
         if ($width == null) {
             $img->fitToHeight($height);
         } else {
             if ($height == null) {
                 $img->fitToWidth($width);
             } else {
                 $img = $img->resize($width, $height);
             }
         }
     }
     $img->save();
     return $output;
 }