mirror of
https://github.com/Intervention/image.git
synced 2025-08-15 10:23:59 +02:00
fixed gif encoding looses transparency
This commit is contained in:
@@ -120,6 +120,7 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
imagealphablending($canvas, false);
|
||||
$transparent = imagecolorallocatealpha($canvas, 255, 255, 255, 127);
|
||||
imagefilledrectangle($canvas, 0, 0, $width, $height, $transparent);
|
||||
imagecolortransparent($canvas, $transparent);
|
||||
imagealphablending($canvas, true);
|
||||
|
||||
// copy original
|
||||
|
@@ -1506,6 +1506,20 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertInternalType('resource', $cln->getCore());
|
||||
}
|
||||
|
||||
public function testGifConversionKeepsTransparency()
|
||||
{
|
||||
$save_as = 'tests/tmp/foo.gif';
|
||||
|
||||
// create gif image from transparent png
|
||||
$img = $this->manager()->make('tests/images/star.png');
|
||||
$img->save($save_as);
|
||||
|
||||
// new gif image should be transparent
|
||||
$img = $this->manager()->make($save_as);
|
||||
$this->assertTransparentPosition($img, 0, 0);
|
||||
@unlink($save_as);
|
||||
}
|
||||
|
||||
private function assertColorAtPosition($color, $img, $x, $y)
|
||||
{
|
||||
$pick = $img->pickColor($x, $y, 'hex');
|
||||
|
@@ -1487,6 +1487,20 @@ class ImagickSystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('Imagick', $cln->getCore());
|
||||
}
|
||||
|
||||
public function testGifConversionKeepsTransparency()
|
||||
{
|
||||
$save_as = 'tests/tmp/foo.gif';
|
||||
|
||||
// create gif image from transparent png
|
||||
$img = $this->manager()->make('tests/images/star.png');
|
||||
$img->save($save_as);
|
||||
|
||||
// new gif image should be transparent
|
||||
$img = $this->manager()->make($save_as);
|
||||
$this->assertTransparentPosition($img, 0, 0);
|
||||
@unlink($save_as);
|
||||
}
|
||||
|
||||
private function assertColorAtPosition($color, $img, $x, $y)
|
||||
{
|
||||
$pick = $img->pickColor($x, $y, 'hex');
|
||||
|
Reference in New Issue
Block a user