Skip to content

Commit ba37249

Browse files
authored
Set color table fourth channel to zero for 1 and L mode when saving BMP (#8889)
2 parents 3a18e55 + c6434db commit ba37249

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/PIL/BmpImagePlugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ def _save(
445445
image = stride * im.size[1]
446446

447447
if im.mode == "1":
448-
palette = b"".join(o8(i) * 4 for i in (0, 255))
448+
palette = b"".join(o8(i) * 3 + b"\x00" for i in (0, 255))
449449
elif im.mode == "L":
450-
palette = b"".join(o8(i) * 4 for i in range(256))
450+
palette = b"".join(o8(i) * 3 + b"\x00" for i in range(256))
451451
elif im.mode == "P":
452452
palette = im.im.getpalette("RGB", "BGRX")
453453
colors = len(palette) // 4

0 commit comments

Comments
 (0)