report a BUG about drawing PIL Image with alpha channel

Skip to first unread message


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 ".\", 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\", 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\", 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\", line 2178, in loadImageFromSRC    self._checkTransparency(im)
 File "C:\Users\Sunboy\AppData\Local\Programs\Python\Python37\lib\site-packages\reportlab\pdfbase\", line 2152, in _checkTransparency
   tc = im.getTransparent()
 File "C:\Users\Sunboy\AppData\Local\Programs\Python\Python37\lib\site-packages\reportlab\lib\", 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,
Reply all
Reply to author
0 new messages