mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 09:31:53 +02:00
ImageMagick PNG encoder test
This commit is contained in:
38
tests/Drivers/Imagick/Encoders/PngEncoderTest.php
Normal file
38
tests/Drivers/Imagick/Encoders/PngEncoderTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Drivers\Imagick\Encoders;
|
||||
|
||||
use Imagick;
|
||||
use ImagickPixel;
|
||||
use Intervention\Image\Collection;
|
||||
use Intervention\Image\Drivers\Imagick\Encoders\PngEncoder;
|
||||
use Intervention\Image\Drivers\Imagick\Frame;
|
||||
use Intervention\Image\Drivers\Imagick\Image;
|
||||
use Intervention\MimeSniffer\MimeSniffer;
|
||||
use Intervention\MimeSniffer\Types\ImagePng;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @requires extension imagick
|
||||
*/
|
||||
final class PngEncoderTest extends TestCase
|
||||
{
|
||||
protected function getTestImage(): Image
|
||||
{
|
||||
$imagick = new Imagick();
|
||||
$imagick->newImage(3, 2, new ImagickPixel('red'), 'jpg');
|
||||
$frame = new Frame($imagick);
|
||||
|
||||
return new Image(new Collection([$frame]));
|
||||
}
|
||||
|
||||
public function testEncode(): void
|
||||
{
|
||||
$image = $this->getTestImage();
|
||||
$encoder = new PngEncoder(75);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertTrue(MimeSniffer::createFromString((string) $result)->matches(new ImagePng()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user