forked from josch/img2pdf
Convert unrecognized colorspaces to RGB
Instead of crashing on an unrecognized colorspace, we now do imgdata.convert('RGB').
This commit is contained in:
parent
c76f1344a5
commit
b726afbb5a
1 changed files with 7 additions and 0 deletions
|
@ -265,8 +265,15 @@ def convert(images, dpi, x, y, title=None, author=None, creator=None, producer=N
|
||||||
else:
|
else:
|
||||||
# because we do not support /CCITTFaxDecode
|
# because we do not support /CCITTFaxDecode
|
||||||
if color == '1':
|
if color == '1':
|
||||||
|
debug_out("Converting colorspace 1 to L", verbose)
|
||||||
imgdata = imgdata.convert('L')
|
imgdata = imgdata.convert('L')
|
||||||
color = '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())
|
imgdata = zlib.compress(imgdata.tostring())
|
||||||
|
|
||||||
# pdf units = 1/72 inch
|
# pdf units = 1/72 inch
|
||||||
|
|
Loading…
Reference in a new issue