fitToWidth() публичный Метод

Fit to width (proportionally resize to specified width)
public fitToWidth ( integer $width )
$width integer
Пример #1
0
 public function testIssue8()
 {
     $excepted = Helper::getExpected(__FUNCTION__ . '.png');
     $actual = Helper::getActual(__FUNCTION__ . '.png');
     $base = Helper::getOrig('issue-8/original.png');
     $img = new Image($base);
     if ($img->getHeight() != $img->getWidth()) {
         if ($img->getWidth() < 175) {
             $img->fitToWidth($img->getWidth());
         } else {
             $img->fitToWidth(175);
         }
     } else {
         $img->bestFit(175, 175);
     }
     $img->saveAs($actual);
     Helper::isFileEq($actual, $excepted);
 }
Пример #2
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;
 }