Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #5931

>>> from PIL import Image
>>> Image.new("RGB", (1, 2)).tobytes()
b'\x00\x00\x00\x00\x00\x00'
>>> Image.new("RGB", (1, 1)).tobytes()
b'\x00\x00\x00'

given this progression, you would expect

>>> Image.new("RGB", (1, 0)).tobytes()

to give

b''

However, instead it currently throws an error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "PIL/Image.py", line 748, in tobytes
    e.setimage(self.im)
SystemError: tile cannot extend outside image

This PR returns an empty bytestring instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

size 0,0 image use .save()/.tobytes() throw SystemError: tile cannot extend outside image

2 participants