1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-31 09:31:53 +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,17 +8,29 @@ use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Encoders\PngEncoder;
use Intervention\Image\Tests\ImagickTestCase;
use Intervention\Image\Tests\Traits\CanDetectInterlacedPng;
#[RequiresPhpExtension('imagick')]
#[CoversClass(\Intervention\Image\Encoders\PngEncoder::class)]
#[CoversClass(\Intervention\Image\Drivers\Imagick\Encoders\PngEncoder::class)]
final class PngEncoderTest extends ImagickTestCase
{
use CanDetectInterlacedPng;
public function testEncode(): void
{
$image = $this->createTestImage(3, 2);
$encoder = new PngEncoder(75);
$encoder = new PngEncoder();
$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));
}
}