From fb04f5f4adb6e8da5456bbf98d753ed46323b9f9 Mon Sep 17 00:00:00 2001 From: ntaylor-86 Date: Tue, 19 Dec 2023 15:23:20 +1000 Subject: [PATCH] Adding webp to the validOutputFormats --- src/Pdf.php | 2 +- tests/PdfTest.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Pdf.php b/src/Pdf.php index 508d0f0..2ac020e 100644 --- a/src/Pdf.php +++ b/src/Pdf.php @@ -19,7 +19,7 @@ class Pdf public $imagick; - protected $validOutputFormats = ['jpg', 'jpeg', 'png']; + protected $validOutputFormats = ['jpg', 'jpeg', 'png', 'webp']; protected $layerMethod = Imagick::LAYERMETHOD_FLATTEN; diff --git a/tests/PdfTest.php b/tests/PdfTest.php index 6d872ff..f987608 100644 --- a/tests/PdfTest.php +++ b/tests/PdfTest.php @@ -50,7 +50,7 @@ expect($imagick)->toBeInstanceOf(Imagick::class); }); -it('will accpect a specified file type and convert to it', function () { +it('will accept a specified file type and convert to it', function () { $imagick = (new Pdf($this->testFile)) ->setOutputFormat('png') ->getImageData('test.png'); @@ -59,7 +59,16 @@ expect($imagick->getFormat())->not->toEqual('jpg'); }); -it('can accepct a layer', function () { +it('will save an image in webp format', function () { + $image = (new Pdf($this->testFile)) + ->setOutputFormat('webp') + ->getImageData('test.webp'); + + expect($image->getFormat())->toEqual('webp'); + expect($image)->not->toEqual('jpg'); +}); + +it('can accept a layer', function () { $image = (new Pdf($this->testFile)) ->setLayerMethod(Imagick::LAYERMETHOD_FLATTEN) ->setResolution(72)