SimpleImage::fit_to_height PHP Method

fit_to_height() public method

Fit to height (proportionally resize to specified height)
public fit_to_height ( integer $height ) : SimpleImage
$height integer
return SimpleImage
    function fit_to_height($height)
    {
        $aspect_ratio = $this->height / $this->width;
        $width = $height / $aspect_ratio;
        return $this->resize($width, $height);
    }

Usage Example

示例#1
0
文件: ajax.php 项目: satson/2gm
         $query = mysql_query("SELECT * FROM vbildergalerien WHERE galID = '" . mysql_escape_string($_POST['_idGallery']) . "'");
         $row = mysql_fetch_array($query);
         $images = $row['galBilder'] . ';' . $imageId;
         mysql_query("UPDATE vbildergalerien SET galBilder='" . $images . "' WHERE galID='" . mysql_escape_string($_POST['_idGallery']) . "'");
         $idGallery = $_POST['_idGallery'];
     }
     $categoryID = $insertId;
     $status = null;
 } else {
     try {
         $newName = mktime() . 'crop_' . $value;
         $imageClass = new SimpleImage('../../../user_upload/' . $value);
         if (!empty($_POST['_height']) && !empty($_POST['_width'])) {
             $imageClass->resize($_POST['_width'], $_POST['_height']);
         } elseif (!empty($_POST['_height'])) {
             $imageClass->fit_to_height($_POST['_height']);
         } else {
             $imageClass->fit_to_width($_POST['_width']);
         }
         //$imageClass->contrast(50);
         $imageClass->save('../../../user_upload/' . $newName, $_POST['_quality']);
         $imageClass->resize(200, 200);
         $imageClass->save('../../../user_upload/thumb_200/' . $newName, 90);
         $imageClass1 = new SimpleImage('../../../user_upload/' . $newName);
         $imageClass1->fit_to_width(400);
         $imageClass1->save('../../../user_upload/thumb_400/' . $newName, $_POST['_quality']);
         $imageClass2 = new SimpleImage('../../../user_upload/' . $newName);
         $imageClass2->fit_to_width(800);
         $imageClass2->save('../../../user_upload/thumb_800/' . $newName, $_POST['_quality']);
         if ($i == 1) {
             mysql_query("INSERT INTO vbildkategorie SET katName='" . $_POST['_newCategory1'] . "',katParent='" . $_POST['_inCategory'] . "'");
All Usage Examples Of SimpleImage::fit_to_height