kopia lustrzana https://github.com/wagtail/wagtail
Change the default WebP quality to 80
This is the value most used, and is the default in Willow too Co-Authored-By: Aman Pandey <74553951+salty-ivy@users.noreply.github.com>pull/10681/head
rodzic
ce4afcd578
commit
96c3d719c2
|
@ -371,12 +371,13 @@ representing the colour you would like to use:
|
|||
|
||||
## Image quality
|
||||
|
||||
Wagtail's JPEG and WebP image quality settings default to 85 (which is quite high). AVIF defaults to 80.
|
||||
Wagtail's JPEG image quality settings default to 85 (which is quite high). AVIF and WebP default to 80.
|
||||
This can be changed either globally or on a per-tag basis.
|
||||
|
||||
### Changing globally
|
||||
|
||||
Use the `WAGTAILIMAGES_AVIF_QUALITY`, `WAGTAILIMAGES_JPEG_QUALITY` and `WAGTAILIMAGES_WEBP_QUALITY` settings to change the global defaults of AVIF, JPEG and WebP quality:
|
||||
Use the `WAGTAILIMAGES_AVIF_QUALITY`, `WAGTAILIMAGES_JPEG_QUALITY` and `WAGTAILIMAGES_WEBP_QUALITY` settings to change
|
||||
the global defaults of AVIF, JPEG and WebP quality:
|
||||
|
||||
```python
|
||||
# settings.py
|
||||
|
|
|
@ -964,7 +964,7 @@ class Filter:
|
|||
elif "webp-quality" in env:
|
||||
quality = env["webp-quality"]
|
||||
else:
|
||||
quality = getattr(settings, "WAGTAILIMAGES_WEBP_QUALITY", 85)
|
||||
quality = getattr(settings, "WAGTAILIMAGES_WEBP_QUALITY", 80)
|
||||
|
||||
return willow.save_as_webp(output, quality=quality)
|
||||
elif output_format == "avif":
|
||||
|
|
|
@ -878,7 +878,7 @@ class TestWebPQualityFilter(TestCase):
|
|||
with patch("PIL.Image.Image.save") as save:
|
||||
fil.run(image, f)
|
||||
|
||||
save.assert_called_with(f, "WEBP", quality=85, lossless=False)
|
||||
save.assert_called_with(f, "WEBP", quality=80, lossless=False)
|
||||
|
||||
def test_webp_quality_filter(self):
|
||||
fil = Filter(spec="width-400|webpquality-40|format-webp")
|
||||
|
@ -893,7 +893,7 @@ class TestWebPQualityFilter(TestCase):
|
|||
|
||||
save.assert_called_with(f, "WEBP", quality=40, lossless=False)
|
||||
|
||||
def test_jpeg_quality_filter_invalid(self):
|
||||
def test_webp_quality_filter_invalid(self):
|
||||
fil = Filter(spec="width-400|webpquality-abc|format-webp")
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
|
|
Ładowanie…
Reference in New Issue