diff --git a/Tests/test_image.py b/Tests/test_image.py index f82b3a947..039eb33d1 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -910,6 +910,9 @@ class TestImage: def test_zero_frombytes(self, size): Image.frombytes("RGB", size, b"") + im = Image.new("RGB", size) + im.frombytes(b"") + def test_has_transparency_data(self): for mode in ("1", "L", "P", "RGB"): im = Image.new(mode, (1, 1)) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 0c93f4dc7..cb092f1ae 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -791,6 +791,9 @@ class Image: but loads data into this image instead of creating a new image object. """ + if self.width == 0 or self.height == 0: + return + # may pass tuple instead of argument list if len(args) == 1 and isinstance(args[0], tuple): args = args[0]