-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
What did you do?
Attempted to open an RLE8-compressed bitmap image.
What did you expect to happen?
The image to display correctly.
What actually happened?
An IOError("Unsupported BMP compression (%d)" % file_info['compression']) was thrown.
We try to open the image in our main program:
def load_image(self, path, canvas):
try:
image = Image.open(path)This calls the BmpImageFile class from BmpImagePlugin.py, which attempts to display the file according to the compression types listed in the dictionary on line 63:
COMPRESSIONS = {
'RAW': 0,
'RLE8': 1,
'RLE4': 2,
'BITFIELDS': 3,
'JPEG': 4,
'PNG': 5
}
RAW, RLE8, RLE4, BITFIELDS, JPEG, PNG = 0, 1, 2, 3, 4, 5After reading header data, the program continues; on line 158, an if statement checks:
if file_info['compression'] == self.BITFIELDS:which evaluates to false. So, the program then jumps to line 190, where it checks whether the file's compression type is RAW:
elif file_info['compression'] == self.RAW:which also evaluates to false. This causes the program to jump the code block to line 193, where the exception is thrown, and causes our main program to fail.
raise IOError("Unsupported BMP compression (%d)" %The code that ultimately throws this exception is found at line 194, in the BmpImagePlugin source.
What are your OS, Python and Pillow versions?
- OS: Windows 10
- Python: 3.6.3
- Pillow: 5.2.0