-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
P mode TGA writing broke in 9.1.0 #6494
Copy link
Copy link
Closed
Labels
Description
What did you do?
In https://github.com/CTimmerman/steganography/blob/main/requirements.txt i changed Pillow>=7.2.0,<9.1.0 to Pillow>=7.2.0,<=9.1.0 and ran pip install --upgrade -r requirements.txt && python test\test_steganography.py
What did you expect to happen?
INFO:root:Testing P TGA...
INFO:root:Cover has 1,992 bits / 249 bytes available. (8-bit header)
INFO:root:Message has 176 bits / 22 bytes: b')[i\xf3\x99\xc1XE'... [41, 91, 105, 243, 153, 193, 88, 69]
INFO:root:Data hidden.
INFO:root:Message okay in P TGA.
What actually happened?
INFO:root:Testing P TGA...
INFO:root:Cover has 1,992 bits / 249 bytes available. (8-bit header)
INFO:root:Message has 272 bits / 34 bytes: b'\x08\xf9\xcd\xf4\xfe\x1f\xd0\x94'... [8, 249, 205, 244, 254, 31, 208, 148]
INFO:root:Data hidden.
ERROR:root:image file is truncated (61 bytes not processed)
Traceback (most recent call last):
File "test\test_steganography.py", line 99, in <module>
test_fuzz()
File "test\test_steganography.py", line 61, in test_fuzz
assert reveal(img) == random_bytes # nosec
File "test\../src\steganography.py", line 163, in reveal
bits = list(get_lowest_bits(cover))
File "test\../src\steganography.py", line 34, in get_lowest_bits
for pixel in img.getdata():
File "C:\Users\C\Documents\code\GitHub\steganography\.venv\lib\site-packages\PIL\Image.py", line 1356, in getdata
self.load()
File "C:\Users\C\Documents\code\GitHub\steganography\.venv\lib\site-packages\PIL\ImageFile.py", line 251, in load
raise OSError(
OSError: image file is truncated (61 bytes not processed)
What are your OS, Python and Pillow versions?
- OS: Microsoft Windows [Version 10.0.19044.1889]
- Python: 3.8.5
- Pillow: 9.1.0
IrfanView 4.54 calls the file generated by Pillow 9.1.0 invalid, whereas output from the same code with Pillow 9.0.1 is no problem. Same with Pillow itself loading it.
from PIL import Image
img = Image.new('P', (100, 20), color="white")
name = 'debug_pillow_9.1.0.tga'
img.save(name)
# Everything seems okay so far, until one tries to use the saved image that was created with the color parameter!
after = Image.open(name).load()
r'''
Using Pillow>=9.1.0:
Traceback (most recent call last):
File "test\test_Pillow_9.1.0.py", line 59, in <module>
after = Image.open(name).load()
File "C:\Users\C\Documents\code\GitHub\steganography\.venv\lib\site-packages\PIL\ImageFile.py", line 195, in load
self.im = Image.core.map_buffer(
ValueError: buffer is not large enough
'''Reactions are currently unavailable