Skip to content

Commit 6146e80

Browse files
DASPRiDclaude
andauthored
feat(imagick): add antialias option to ImagickImageBackEnd (#209) (#235)
Add a $antialias constructor parameter (default true) to allow disabling antialiasing for sharper images, smaller file sizes, and better nearest-neighbor scalability. Closes #209 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ec5d4c4 commit 6146e80

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎src/Renderer/Image/ImagickImageBackEnd.php‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ final class ImagickImageBackEnd implements ImageBackEndInterface
4040

4141
private ?int $matrixIndex;
4242

43-
public function __construct(string $imageFormat = 'png', int $compressionQuality = 100)
43+
private bool $antialias;
44+
45+
public function __construct(string $imageFormat = 'png', int $compressionQuality = 100, bool $antialias = true)
4446
{
4547
if (! class_exists(Imagick::class)) {
4648
throw new RuntimeException('You need to install the imagick extension to use this back end');
4749
}
4850

4951
$this->imageFormat = $imageFormat;
5052
$this->compressionQuality = $compressionQuality;
53+
$this->antialias = $antialias;
5154
}
5255

5356
public function new(int $size, ColorInterface $backgroundColor) : void
@@ -57,6 +60,12 @@ public function new(int $size, ColorInterface $backgroundColor) : void
5760
$this->image->setImageFormat($this->imageFormat);
5861
$this->image->setCompressionQuality($this->compressionQuality);
5962
$this->draw = new ImagickDraw();
63+
64+
if (! $this->antialias) {
65+
$this->image->setAntiAlias(false);
66+
$this->draw->setStrokeAntialias(false);
67+
}
68+
6069
$this->gradientCount = 0;
6170
$this->matrices = [new TransformationMatrix()];
6271
$this->matrixIndex = 0;

0 commit comments

Comments
 (0)