Robin Becker  committed 7df61e3 ImageReader handle png indexed with transparency specially

  • Participants
  • Parent commits b07c2c8
  • Branches default

Comments (0)

Files changed (2)

File src/reportlab/lib/

                         im = im.convert('RGB')
                         self.mode = 'RGB'
                     elif mode not in ('L','RGB','CMYK'):
-                        im = im.convert('RGB')
+                        if im.format=='PNG' and im.mode=='P' and 'transparency' in
+                            im = im.convert('RGBA')
+                            self._dataA = ImageReader(im.split()[3])
+                            im = im.convert('RGB')
+                        else:
+                            im = im.convert('RGB')
                         self.mode = 'RGB'
                     if hasattr(im, 'tobytes'):  #make pillow and PIL both happy, for now
                         self._data = im.tobytes()

File tests/

     if haveImages:
         c.drawImage(gif, 1*inch, 1.2*inch, w, h, mask=myMask)
         c.drawImage(gif, 3*inch, 1.2*inch, w, h, mask='auto')
+        c.drawImage(os.path.join(testsFolder,'test-rgba.png'),5*inch,1.2*inch,width=10,height=10,mask='auto')
+        c.drawImage(os.path.join(testsFolder,'test-indexed.png'),5.5*inch,1.2*inch,width=10,height=10,mask='auto')
         c.rect(1*inch, 1.2*inch, w, h)
         c.rect(3*inch, 1.2*inch, w, h)