report a BUG about drawing PIL Image with alpha channel

16 views
Skip to first unread message

BoyInTheSun

unread,
Mar 24, 2022, 9:26:56 AMMar 24
to reportlab-users
Thank you for leaving this contact information and watching my email!

When I try to draw a PIL Image with alpha channel, I found this error:

Traceback (most recent call last):
 File ".\json2pdf.py", line 73, in 
   c.drawImage(ImageReader(new_image), int(item['p']['x']), data['page']['ph'] - int(item['p']['y']) - int(item['c']['ih']), mask='auto')   
 File "C:\Users\Sunboy\AppData\Local\Programs\Python\Python37\lib\site-packages\reportlab\pdfgen\canvas.py", line 980, in drawImage
   imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
 File "C:\Users\Sunboy\AppData\Local\Programs\Python\Python37\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2074, in __init__        
   self.loadImageFromSRC(source)   #it is already a PIL Image
 File "C:\Users\Sunboy\AppData\Local\Programs\Python\Python37\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2178, in loadImageFromSRC    self._checkTransparency(im)
 File "C:\Users\Sunboy\AppData\Local\Programs\Python\Python37\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2152, in _checkTransparency
   tc = im.getTransparent()
 File "C:\Users\Sunboy\AppData\Local\Programs\Python\Python37\lib\site-packages\reportlab\lib\utils.py", line 781, in getTransparent        
   return palette[transparency:transparency+3]
TypeError: can't concat int to bytes

I tried to find the reason, but failed.
type(transparency) is bytes unexpectedly.

I don't know how to add attachment. If necessary, I can provide my code, it may be useful.

By the way, my environment is Python3.7.4, reportlab3.6.8.

Looking forward to hearing from you! 
Thank you a lot!


Yours sincerely,
BoyInTheSun
Reply all
Reply to author
Forward
0 new messages