1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-23 22:12:51 +02:00

Add option to encode interlaced PNG format

This commit is contained in:
Oliver Vogel
2024-04-14 09:24:26 +02:00
parent 968f9e498e
commit 490b8ae5c4
6 changed files with 62 additions and 4 deletions

View File

@@ -8,12 +8,15 @@ use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Encoders\PngEncoder;
use Intervention\Image\Tests\GdTestCase;
use Intervention\Image\Tests\Traits\CanDetectInterlacedPng;
#[RequiresPhpExtension('gd')]
#[CoversClass(\Intervention\Image\Encoders\PngEncoder::class)]
#[CoversClass(\Intervention\Image\Drivers\Gd\Encoders\PngEncoder::class)]
final class PngEncoderTest extends GdTestCase
{
use CanDetectInterlacedPng;
public function testEncode(): void
{
$image = $this->createTestImage(3, 2);
@@ -21,4 +24,13 @@ final class PngEncoderTest extends GdTestCase
$result = $encoder->encode($image);
$this->assertMediaType('image/png', (string) $result);
}
public function testEncodeInterlaced(): void
{
$image = $this->createTestImage(3, 2);
$encoder = new PngEncoder(interlaced: true);
$result = $encoder->encode($image);
$this->assertMediaType('image/png', (string) $result);
$this->assertTrue($this->isInterlacedPng((string) $result));
}
}