mirror of
https://github.com/Intervention/image.git
synced 2025-08-05 21:37:25 +02:00
bugfix
This commit is contained in:
@@ -504,8 +504,10 @@ class Image
|
|||||||
|
|
||||||
// create new canvas
|
// create new canvas
|
||||||
$image = imagecreatetruecolor($width, $height);
|
$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;
|
$bgcolor = is_null($bgcolor) ? '000000' : $bgcolor;
|
||||||
imagefill($image, 0, 0, $this->parseColor($bgcolor));
|
imagefill($image, 0, 0, $this->parseColor($bgcolor));
|
||||||
}
|
}
|
||||||
|
@@ -547,6 +547,18 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$transparency_2 = $img->pickColor(899, 699, 'array');
|
$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_1);
|
||||||
$this->assertEquals(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0.0), $transparency_2);
|
$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()
|
public function testCropImage()
|
||||||
|
Reference in New Issue
Block a user