Skip to content

Commit 74584b9

Browse files
committed
Avoid PIL deprecation warning
PIL loudly deprecated (with a quite short deprecation window) the Image.NEAREST export. Handle it for both new/old versions.
1 parent 01d54a6 commit 74584b9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sogs/routes/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010
import qrencode
1111

12-
from PIL.Image import NEAREST
12+
import PIL.Image
13+
14+
if hasattr(PIL.Image, 'Resampling'):
15+
NEAREST = PIL.Image.Resampling.NEAREST
16+
else:
17+
NEAREST = PIL.Image.NEAREST
1318

1419

1520
views = Blueprint('views', __name__)

0 commit comments

Comments
 (0)