Skip to content

Commit

Permalink
Merge pull request #7506 from ddevsr/quality-option
Browse files Browse the repository at this point in the history
feat: `GDHandler` make `WebP` with option quality
  • Loading branch information
kenjis authored May 25, 2023
2 parents 46cf29b + 964a504 commit 613c2bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion system/Images/Handlers/GDHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function save(?string $target = null, int $quality = 90): bool
throw ImageException::forInvalidImageCreate(lang('Images.webpNotSupported'));
}

if (! @imagewebp($this->resource, $target)) {
if (! @imagewebp($this->resource, $target, $quality)) {
throw ImageException::forSaveFailed();
}
break;
Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/changelogs/v4.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Libraries

- **Validation:** Added ``Validation::getValidated()`` method that gets
the actual validated data. See :ref:`validation-getting-validated-data` for details.
- **Images:** The option ``$quality`` can now be used to compress WebP images.

Helpers and Functions
=====================
Expand Down Expand Up @@ -119,6 +120,7 @@ Message Changes
Changes
*******

- **Images:** The default quality for WebP in ``GDHandler`` has been changed from 80 to 90.
- **Config:** The deprecated Cookie items in **app/Config/App.php** has been removed.
- **Config:** Routing settings have been moved to **app/Config/Routing.php** config file.
See :ref:`Upgrading Guide <upgrade-440-config-routing>`.
Expand Down
4 changes: 3 additions & 1 deletion user_guide_src/source/libraries/images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ Image Quality

``save()`` can take an additional parameter ``$quality`` to alter the resulting image
quality. Values range from 0 to 100 with 90 being the framework default. This parameter
only applies to JPEG images and will be ignored otherwise:
only applies to JPEG and WEBP images, will be ignored otherwise:

.. note:: The parameter ``$quality`` for WebP can be used since v4.4.0.

.. literalinclude:: images/005.php

Expand Down

0 comments on commit 613c2bf

Please sign in to comment.