mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-05 06:00:58 +03:00
minor addition
This commit is contained in:
parent
a466b3e099
commit
5cd1b9f01e
|
@ -355,7 +355,7 @@ def getheader(im, palette=None, info=None):
|
||||||
# create the global palette
|
# create the global palette
|
||||||
if im.mode == "P":
|
if im.mode == "P":
|
||||||
# colour palette
|
# colour palette
|
||||||
if countUsedPaletteColors > 0:
|
if countUsedPaletteColors > 0 and countUsedPaletteColors < 256:
|
||||||
paletteBytes = b"";
|
paletteBytes = b"";
|
||||||
# pick only the used colors from the palette
|
# pick only the used colors from the palette
|
||||||
for i in usedPaletteColors:
|
for i in usedPaletteColors:
|
||||||
|
@ -364,7 +364,7 @@ def getheader(im, palette=None, info=None):
|
||||||
paletteBytes = im.im.getpalette("RGB")[:768]
|
paletteBytes = im.im.getpalette("RGB")[:768]
|
||||||
else:
|
else:
|
||||||
# greyscale
|
# greyscale
|
||||||
if countUsedPaletteColors > 0:
|
if countUsedPaletteColors > 0 and countUsedPaletteColors < 256:
|
||||||
paletteBytes = b"";
|
paletteBytes = b"";
|
||||||
# add only the used grayscales to the palette
|
# add only the used grayscales to the palette
|
||||||
for i in usedPaletteColors:
|
for i in usedPaletteColors:
|
||||||
|
@ -391,7 +391,7 @@ def getheader(im, palette=None, info=None):
|
||||||
# end of screen descriptor header
|
# end of screen descriptor header
|
||||||
|
|
||||||
# add the missing amount of bytes
|
# add the missing amount of bytes
|
||||||
# the palette can only be 2<<n in size
|
# the palette has to be 2<<n in size
|
||||||
actualTargetSizeDiff = (2<<colorTableSize) - len(paletteBytes)//3
|
actualTargetSizeDiff = (2<<colorTableSize) - len(paletteBytes)//3
|
||||||
if actualTargetSizeDiff > 0:
|
if actualTargetSizeDiff > 0:
|
||||||
paletteBytes += o8(0) * 3 * actualTargetSizeDiff
|
paletteBytes += o8(0) * 3 * actualTargetSizeDiff
|
||||||
|
|
Loading…
Reference in New Issue
Block a user