mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-06 06:03:14 +03:00
Try to fix tests
Choked on roundtrip, where a P;1 image was returned instead of a 1 image.
This commit is contained in:
parent
7b657f6887
commit
f953b98285
|
@ -171,8 +171,13 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
else:
|
else:
|
||||||
padding = file_info['palette_padding']
|
padding = file_info['palette_padding']
|
||||||
palette = read(padding * file_info['colors'])
|
palette = read(padding * file_info['colors'])
|
||||||
|
greyscale = True
|
||||||
|
indices = (0, 255) if file_info['colors'] == 2 else list(range(file_info['colors']))
|
||||||
#------------------- Check if greyscale and ignore palette if so
|
#------------------- Check if greyscale and ignore palette if so
|
||||||
greyscale = all([palette[ind] == palette[ind+1] == palette[ind+2] == ind / padding for ind in range(0, len(palette), padding)])
|
for ind in indices:
|
||||||
|
rgb = palette[ind*padding:ind*padding + 3]
|
||||||
|
if rgb != o8(ind) * 3:
|
||||||
|
greyscale = False
|
||||||
#--------- If all colors are grey, white or black, ditch palette
|
#--------- If all colors are grey, white or black, ditch palette
|
||||||
if greyscale:
|
if greyscale:
|
||||||
self.mode = "1" if file_info['colors'] == 2 else "L"
|
self.mode = "1" if file_info['colors'] == 2 else "L"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user