Skip to content

Commit 25c039a

Browse files
committed
Make PIL optional
1 parent 39325d6 commit 25c039a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pslab/external/display.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
import json
1717
import os.path
1818

19-
from PIL import Image
19+
try:
20+
from PIL import Image
21+
22+
HASPIL = True
23+
except ImportError:
24+
HASPIL = False
2025

2126
from pslab.bus import I2CSlave
2227

@@ -415,6 +420,11 @@ def display(self, image: Image):
415420
image : Image
416421
A PIL.Image instance.
417422
"""
423+
if not HASPIL:
424+
raise ImportError(
425+
"Displaying images requires PIL, but it is not installed."
426+
)
427+
418428
if not image.size == (128, 64):
419429
image = image.resize((128, 64))
420430

0 commit comments

Comments
 (0)