Skip to content

Commit

Permalink
add Avif Support (#207)
Browse files Browse the repository at this point in the history
* add avif support

* Fix styling

* update supported formats

---------

Co-authored-by: ariaieboy <[email protected]>
  • Loading branch information
ariaieboy and ariaieboy authored Dec 15, 2023
1 parent 7825aa2 commit d029e0e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ The following image formats are tested and supported by the package. If your GD/
| png |||
| gif |||
| webp |||
| avif |||
| heic |||
| tiff |||
3 changes: 3 additions & 0 deletions src/Drivers/Gd/GdDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public function save(?string $path = null): static
case 'webp':
imagewebp($this->image, $path);
break;
case 'avif':
imageavif($this->image, $path);
break;
default:
throw UnsupportedImageFormat::make($extension);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ImageFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$driver->loadFile(getTestJpg())->save($targetFile);

expect($targetFile)->toHaveMime("image/$format");
})->with('drivers', ['jpeg', 'gif', 'png', 'webp']);
})->with('drivers', ['jpeg', 'gif', 'png', 'webp', 'avif']);

it('can save tiff', function () {
$format = 'tiff';
Expand Down
4 changes: 2 additions & 2 deletions tests/Manipulations/QualityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

$driver->loadFile(getTestJpg())->quality($quality)->save($targetFile);

expect($targetFile)->toBeFile();
})->with('drivers')->with(['jpg', 'png', 'webp'])->with([10, 50, 90]);
expect($targetFile)->toBeFile()->toHaveMime("image/$format");
})->with('drivers')->with(['jpeg', 'png', 'webp', 'avif'])->with([10, 50, 90]);

0 comments on commit d029e0e

Please sign in to comment.