From ce40529adc06867f5426583ba070bfd64f119ee3 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 25 Mar 2020 07:34:03 +1100 Subject: [PATCH] Added deprecation warning --- Tests/test_file_jpeg2k.py | 3 ++- src/PIL/Jpeg2KImagePlugin.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index 1324c40c7df..a77c53bf056 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -129,7 +129,8 @@ def test_reduce(): with Image.open("Tests/images/test-card-lossless.jp2") as im: assert callable(im.reduce) - im.reduce = 2 + with pytest.warns(DeprecationWarning): + im.reduce = 2 assert im.reduce == 2 im.load() diff --git a/src/PIL/Jpeg2KImagePlugin.py b/src/PIL/Jpeg2KImagePlugin.py index 48c0639da2e..11a85be0c65 100644 --- a/src/PIL/Jpeg2KImagePlugin.py +++ b/src/PIL/Jpeg2KImagePlugin.py @@ -15,6 +15,7 @@ import io import os import struct +import warnings from . import Image, ImageFile @@ -213,6 +214,11 @@ def reduce(self): @reduce.setter def reduce(self, value): + warnings.warn( + 'The reduce property of Jpeg2KImageFile is deprecated, and will' + ' be removed in a future version. Use the load_reduce method instead.', + DeprecationWarning + ) self.load_reduce = value def load(self):