diff --git a/src/Renderer/Image/ImagickImageBackEnd.php b/src/Renderer/Image/ImagickImageBackEnd.php index a16a663..1270ac9 100644 --- a/src/Renderer/Image/ImagickImageBackEnd.php +++ b/src/Renderer/Image/ImagickImageBackEnd.php @@ -40,7 +40,9 @@ final class ImagickImageBackEnd implements ImageBackEndInterface private ?int $matrixIndex; - public function __construct(string $imageFormat = 'png', int $compressionQuality = 100) + private bool $antialias; + + public function __construct(string $imageFormat = 'png', int $compressionQuality = 100, bool $antialias = true) { if (! class_exists(Imagick::class)) { throw new RuntimeException('You need to install the imagick extension to use this back end'); @@ -48,6 +50,7 @@ public function __construct(string $imageFormat = 'png', int $compressionQuality $this->imageFormat = $imageFormat; $this->compressionQuality = $compressionQuality; + $this->antialias = $antialias; } public function new(int $size, ColorInterface $backgroundColor) : void @@ -57,6 +60,12 @@ public function new(int $size, ColorInterface $backgroundColor) : void $this->image->setImageFormat($this->imageFormat); $this->image->setCompressionQuality($this->compressionQuality); $this->draw = new ImagickDraw(); + + if (! $this->antialias) { + $this->image->setAntiAlias(false); + $this->draw->setStrokeAntialias(false); + } + $this->gradientCount = 0; $this->matrices = [new TransformationMatrix()]; $this->matrixIndex = 0;