mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Return an empty bytestring from tobytes() for an empty image
This commit is contained in:
parent
0648692b2c
commit
b5160591bc
|
@ -786,6 +786,11 @@ class TestImage:
|
|||
34665: 196,
|
||||
}
|
||||
|
||||
@pytest.mark.parametrize("size", ((1, 0), (0, 1), (0, 0)))
|
||||
def test_zero_tobytes(self, size):
|
||||
im = Image.new("RGB", size)
|
||||
assert im.tobytes() == b""
|
||||
|
||||
def test_categories_deprecation(self):
|
||||
with pytest.warns(DeprecationWarning):
|
||||
assert hopper().category == 0
|
||||
|
|
|
@ -716,6 +716,9 @@ class Image:
|
|||
|
||||
self.load()
|
||||
|
||||
if self.width == 0 or self.height == 0:
|
||||
return b""
|
||||
|
||||
# unpack data
|
||||
e = _getencoder(self.mode, encoder_name, args)
|
||||
e.setimage(self.im)
|
||||
|
|
Loading…
Reference in New Issue
Block a user