Pop\Image\Gd::resizeToHeight PHP Method

resizeToHeight() public method

Resize the image object to the height parameter passed.
public resizeToHeight ( integer | string $hgt ) : mixed
$hgt integer | string
return mixed
    public function resizeToHeight($hgt)
    {
        $scale = $hgt / $this->height;
        $wid = round($this->width * $scale);
        // Create a new image output resource.
        $this->createResource();
        $this->output = imagecreatetruecolor($wid, $hgt);
        // Copy newly sized image to the output resource.
        $this->copyImage($wid, $hgt);
        return $this;
    }

Usage Example

コード例 #1
0
ファイル: GdTest.php プロジェクト: nicksagona/PopPHP
 public function testGif()
 {
     $i = new Gd(__DIR__ . '/../tmp/test.gif');
     $i->resizeToHeight(120);
     $this->assertEquals(120, $i->getHeight());
 }