1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 20:28:21 +01:00
This commit is contained in:
Oliver Vogel 2014-04-07 17:14:07 +02:00
parent 2cd95af911
commit 6c0574ddba
2 changed files with 15 additions and 1 deletions

View File

@ -504,8 +504,10 @@ class Image
// create new canvas
$image = imagecreatetruecolor($width, $height);
imagealphablending($image, false);
imagesavealpha($image, true);
if ($width > $this->width || $height > $this->height) {
if ($width > $this->width or $height > $this->height) {
$bgcolor = is_null($bgcolor) ? '000000' : $bgcolor;
imagefill($image, 0, 0, $this->parseColor($bgcolor));
}

View File

@ -547,6 +547,18 @@ class ImageTest extends PHPUnit_Framework_Testcase
$transparency_2 = $img->pickColor(899, 699, 'array');
$this->assertEquals(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0.0), $transparency_1);
$this->assertEquals(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0.0), $transparency_2);
// preserve transparency when resizing canvas
$img = new Image('public/circle.png');
$img->resizeCanvas(40, 40, 'center');
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertInternalType('int', $img->width);
$this->assertInternalType('int', $img->height);
$this->assertEquals($img->width, 40);
$this->assertEquals($img->height, 40);
$this->assertEquals(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0.0), $img->pickColor(0, 0, 'array'));
$this->assertEquals(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0.8), $img->pickColor(20, 20, 'array'));
}
public function testCropImage()