Convert unrecognized colorspaces to RGB

Instead of crashing on an unrecognized colorspace, we now do
imgdata.convert('RGB').
This commit is contained in:
Ryan C. Thompson 2014-11-05 23:47:42 -08:00
parent c76f1344a5
commit b726afbb5a

View file

@ -265,8 +265,15 @@ def convert(images, dpi, x, y, title=None, author=None, creator=None, producer=N
else:
# because we do not support /CCITTFaxDecode
if color == '1':
debug_out("Converting colorspace 1 to L", verbose)
imgdata = imgdata.convert('L')
color = 'L'
elif color in ("RGB", "L"):
debug_out("Colorspace is OK: %s"%color, verbose)
else:
debug_out("Converting colorspace %s to RGB"%color, verbose)
imgdata = imgdata.convert('RGB')
color = imgdata.mode
imgdata = zlib.compress(imgdata.tostring())
# pdf units = 1/72 inch