Skip to content

Commit 371e169

Browse files
committed
Change default file type to AVIF (Baseline 2024)
1 parent 24d522b commit 371e169

File tree

9 files changed

+224
-229
lines changed

9 files changed

+224
-229
lines changed

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ PICTURES = {
9191
},
9292
"GRID_COLUMNS": 12,
9393
"CONTAINER_WIDTH": 1200,
94-
"FILE_TYPES": ["WEBP"],
94+
"FILE_TYPES": ["AVIF"],
9595
"PIXEL_DENSITIES": [1, 2],
9696
"USE_PLACEHOLDERS": True,
9797
"QUEUE_NAME": "pictures",
@@ -199,12 +199,6 @@ Baseline 2024 and is supported by all major browsers. Additionally, most modern
199199
devices will have hardware acceleration for AVIF decoding. This will not only
200200
reduce network IO but speed up page rendering.
201201

202-
> [!NOTE]
203-
> Pillow 11.2.1 shipped without AVIF binaries.
204-
> You will need to [install Pillow from source][libavif-install] for AVIF support.
205-
> This should be resolved in upcoming releases, once
206-
> [#8858](https://github.com/python-pillow/Pillow/pull/8858) has been merged.
207-
208202
Should you still serve IE11, use add `JPEG` to the list. But, beware, this may
209203
drastically increase your storage needs.
210204

@@ -256,7 +250,7 @@ from rest_framework import serializers
256250
from pictures.contrib.rest_framework import PictureField
257251

258252
class PictureSerializer(serializers.Serializer):
259-
picture = PictureField(aspect_ratios=["16/9"], file_types=["WEBP"])
253+
picture = PictureField(aspect_ratios=["16/9"], file_types=["AVIF"])
260254
```
261255

262256
You also may provide optional GET parameters to the serializer

pictures/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_settings():
1717
},
1818
"GRID_COLUMNS": 12,
1919
"CONTAINER_WIDTH": 1200,
20-
"FILE_TYPES": ["WEBP"],
20+
"FILE_TYPES": ["AVIF"],
2121
"PIXEL_DENSITIES": [1, 2],
2222
"USE_PLACEHOLDERS": settings.DEBUG,
2323
"QUEUE_NAME": "pictures",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ classifiers = [
3434
"Framework :: Django :: 5.2",
3535
]
3636
requires-python = ">=3.9"
37-
dependencies = ["django>=4.2.0", "pillow>=9.0.0"]
37+
dependencies = ["django>=4.2.0", "pillow>=11.3.0"]
3838

3939
[project.optional-dependencies]
4040
test = [

tests/contrib/test_cleanup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_delete(self, stub_worker, image_upload_file):
1919
stub_worker.join()
2020

2121
name = obj.picture.name
22-
path = obj.picture.aspect_ratios["16/9"]["WEBP"][100].path
22+
path = obj.picture.aspect_ratios["16/9"]["AVIF"][100].path
2323
assert default_storage.exists(name)
2424
assert path.exists()
2525
with transaction.atomic(get_using(obj)):

tests/contrib/test_rest_framework.py

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

tests/test_migrations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class Meta:
133133
migration = migrations.AlterPictureField("profile", "picture", PictureField())
134134
from_field = Profile._meta.get_field("picture")
135135

136-
path = luke.picture.aspect_ratios["16/9"]["WEBP"][100].path
136+
path = luke.picture.aspect_ratios["16/9"]["AVIF"][100].path
137137
assert path.exists()
138138

139139
migration.update_pictures(from_field, ToModel)
@@ -143,7 +143,7 @@ class Meta:
143143
luke.refresh_from_db()
144144
path = (
145145
ToModel.objects.get(pk=luke.pk)
146-
.picture.aspect_ratios["21/9"]["WEBP"][100]
146+
.picture.aspect_ratios["21/9"]["AVIF"][100]
147147
.path
148148
)
149149
assert path.exists()
@@ -175,7 +175,7 @@ class Meta:
175175
def test_from_picture_field(self, stub_worker, image_upload_file):
176176
luke = Profile.objects.create(name="Luke", picture=image_upload_file)
177177
stub_worker.join()
178-
path = luke.picture.aspect_ratios["16/9"]["WEBP"][100].path
178+
path = luke.picture.aspect_ratios["16/9"]["AVIF"][100].path
179179
assert path.exists()
180180
migration = migrations.AlterPictureField("profile", "picture", PictureField())
181181
migration.from_picture_field(Profile)
@@ -207,7 +207,7 @@ class Meta:
207207
luke.refresh_from_db()
208208
path = (
209209
Profile.objects.get(pk=luke.pk)
210-
.picture.aspect_ratios["16/9"]["WEBP"][100]
210+
.picture.aspect_ratios["16/9"]["AVIF"][100]
211211
.path
212212
)
213213
assert path.exists()
@@ -267,7 +267,7 @@ class Meta:
267267
luke.refresh_from_db()
268268
path = (
269269
Profile.objects.get(pk=luke.pk)
270-
.picture.aspect_ratios["16/9"]["WEBP"][100]
270+
.picture.aspect_ratios["16/9"]["AVIF"][100]
271271
.path
272272
)
273273
assert path.exists()

0 commit comments

Comments
 (0)