Skip to content

Commit

Permalink
Merge pull request #221 from ntaylor-86/webp-support
Browse files Browse the repository at this point in the history
Adding webp to the validOutputFormats
  • Loading branch information
patinthehat authored Mar 7, 2024
2 parents 7cf8005 + fb04f5f commit d47f1fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Pdf

public $imagick;

protected $validOutputFormats = ['jpg', 'jpeg', 'png'];
protected $validOutputFormats = ['jpg', 'jpeg', 'png', 'webp'];

protected $layerMethod = Imagick::LAYERMETHOD_FLATTEN;

Expand Down
13 changes: 11 additions & 2 deletions tests/PdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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)
Expand Down

0 comments on commit d47f1fc

Please sign in to comment.