Re: Transparent png

Arkadi Colson <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Organization Smartbit bvba
Message-ID <[email protected]>
Thanks a lot for the help. It's working great!


On 24-05-17 11:54, Robin Becker wrote:
> On 24/05/2017 10:36, Arkadi Colson wrote:
>> Ah ok. It's that simple :-). Are you going to implement it in one of 
>> the next
>> versions or what's the next step?
>>
>> Thanks already for your effort!
>>
> I have tested a small change to the ImageReader class which seems to 
> do the trick for PDF at least. Our graphics stuff is way behind anyhow 
> so it won't work there. It will appear at bitbucket shortly. Or wait 
> for version 3.4.12 to appear at our non-release pypi 
> https://www.reportlab.com/pypi).
>
>
> In the meantime if you know how to patch the source you could try this
>
> diff -r 823a45c95ed8 src/reportlab/lib/utils.py
> --- a/src/reportlab/lib/utils.py        Tue May 23 15:30:14 2017 +0100
> +++ b/src/reportlab/lib/utils.py        Wed May 24 10:51:47 2017 +0100
> @@ -882,11 +882,12 @@
>                  else:
>                      im = self._image
>                      mode = self.mode = im.mode
> -                    if mode=='RGBA':
> +                    if mode in ('LA','RGBA'):
>                          if Image.VERSION.startswith('1.1.7'): im.load()
> -                        self._dataA = ImageReader(im.split()[3])
> -                        im = im.convert('RGB')
> -                        self.mode = 'RGB'
> +                        self._dataA = ImageReader(im.split()[3 if 
> mode=='RGBA' else 1])
> +                        nm = mode[:-1]
> +                        im = im.convert(nm)
> +                        self.mode = nm
>                      elif mode not in ('L','RGB','CMYK'):
>                          if im.format=='PNG' and im.mode=='P' and 
> 'transparency' in im.info:
>                              im = im.convert('RGBA')
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.