mirror of
https://github.com/Intervention/image.git
synced 2025-01-18 04:38:26 +01:00
added widen and heighten methods
This commit is contained in:
parent
81c61cd35c
commit
62ec665340
@ -413,6 +413,28 @@ class Image
|
||||
return $this->resize($width, $height, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize image to new width, constraining proportions
|
||||
*
|
||||
* @param integer $width
|
||||
* @return Image
|
||||
*/
|
||||
public function widen($width)
|
||||
{
|
||||
return $this->resize($width, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize image to new height, constraining proportions
|
||||
*
|
||||
* @param integer $height
|
||||
* @return Image
|
||||
*/
|
||||
public function heighten($height)
|
||||
{
|
||||
return $this->resize(null, $height, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize image canvas
|
||||
*
|
||||
|
@ -285,6 +285,40 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
||||
$this->assertEquals($img->height, $original_height);
|
||||
}
|
||||
|
||||
public function testWidenImage()
|
||||
{
|
||||
$img = $this->getTestImage();
|
||||
|
||||
$img->widen(100);
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
$this->assertEquals($img->width, 100);
|
||||
$this->assertEquals($img->height, 75);
|
||||
|
||||
$img->widen(1000);
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
$this->assertEquals($img->width, 1000);
|
||||
$this->assertEquals($img->height, 750);
|
||||
}
|
||||
|
||||
public function testHeightenImage()
|
||||
{
|
||||
$img = $this->getTestImage();
|
||||
|
||||
$img->heighten(150);
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
$this->assertEquals($img->width, 200);
|
||||
$this->assertEquals($img->height, 150);
|
||||
|
||||
$img->heighten(900);
|
||||
$this->assertInternalType('int', $img->width);
|
||||
$this->assertInternalType('int', $img->height);
|
||||
$this->assertEquals($img->width, 1200);
|
||||
$this->assertEquals($img->height, 900);
|
||||
}
|
||||
|
||||
public function testResizeCanvas()
|
||||
{
|
||||
$img = $this->getTestImage();
|
||||
|
Loading…
x
Reference in New Issue
Block a user