Skip to content

Commit a5566d8

Browse files
committed
fix(dep): make avif pillow package optional
1 parent 420902f commit a5566d8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dependencies = [
1111
"numpy",
1212
"packaging",
1313
"pillow",
14-
"pillow-avif-plugin"
1514
]
1615
requires-python = ">=3.9"
1716
readme = "README.rst"
@@ -34,6 +33,9 @@ dev = [
3433
"ruff",
3534
"pytest",
3635
]
36+
avif = [
37+
"pillow-avif-plugin",
38+
]
3739
turbo = [
3840
"PyTurboJPEG", # Requires libjpeg-turbo to be available on the system
3941
]

trame_rca/encoders/pil.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
from numpy.typing import NDArray
1+
from contextlib import suppress
22
from io import BytesIO
3-
import pillow_avif # noqa
3+
4+
from numpy.typing import NDArray
45
from PIL import Image
5-
from trame_rca.encoders.img import TO_IMAGE_TYPE, TO_IMAGE_FORMAT
6+
7+
from trame_rca.encoders.img import TO_IMAGE_FORMAT, TO_IMAGE_TYPE
8+
9+
# Not supported on all platform so make it optional
10+
with suppress(ImportError):
11+
import pillow_avif # noqa
612

713

814
def encode(

0 commit comments

Comments
 (0)