-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
PNG: unnecessary padding in PLTE #2202
Copy link
Copy link
Closed
Labels
BugAny unexpected behavior, until confirmed feature.Any unexpected behavior, until confirmed feature.
Milestone
Description
Pillow incorrectly enforces a minimum of 2 palette entries.
from PIL import Image
img = Image.new(size = (1, 1), mode = 'P')
img.putpalette((1, 1, 1))
img.save('file.png')$ pngcheck -v file.png
...
1 x 1 image, 1-bit palette, non-interlaced
chunk PLTE at offset 0x00025, length 6: 2 palette entries
...And pads the palette to bit ** 2 entries.
from PIL import Image
img = Image.new(size = (3, 3), mode = 'P')
img.putpalette((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5)) # 5
img.save('file.png')$ pngcheck -v file.png
...
3 x 3 image, 4-bit palette, non-interlaced
chunk PLTE at offset 0x00025, length 48: 16 palette entries
...It's neither required nor recommended.
It is permissible to have fewer entries than the bit depth would allow.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugAny unexpected behavior, until confirmed feature.Any unexpected behavior, until confirmed feature.