[reportlab-users] Transparent png

Arkadi Colson arkadi at smartbit.be
Wed May 24 04:22:35 EDT 2017


Hi

I'm not really sure how to get the mode. I attached the image. Perhaps 
you can give it a try?
Thanks a lot!

Arkadi


On 24-05-17 10:01, Robin Becker wrote:
>
> On 24/05/2017 08:17, Arkadi Colson wrote:
>> I tried it and the result is this:
>>
>> The black square should be a transparent image and looks like this:
>>
>> Both are png images.
>> The first one which is appearing correctly is "PNG image data, 48 x 48,
>> 8-bit/color RGBA, non-interlaced". The black square is "PNG image 
>> data, 48 x 48,
>> 8-bit gray+alpha, non-interlaced".
>>
>> Any idea why the "gray+alpha" isn't showing up correctly?
>>
>> Thx!
>>
>
> Hi Arkadi,
>
> I'm almost sure that we don't support lots of stuff regarding colour 
> mappings especially with images.
>
> Since PNG is not native for PDF I think we're just doing this for PNG
>
> >     if mode=='RGBA':
> >         if Image.VERSION.startswith('1.1.7'): im.load()
> >         self._dataA = ImageReader(im.split()[3])
> >         im = im.convert('RGB')
> >         self.mode = 'RGB'
> >     elif mode not in ('L','RGB','CMYK'):
> >         if im.format=='PNG' and im.mode=='P' and 'transparency' in 
> im.info:
> >             im = im.convert('RGBA')
> >             self._dataA = ImageReader(im.split()[3])
> >             im = im.convert('RGB')
> >         else:
> >             im = im.convert('RGB')
> >         self.mode = 'RGB'
>
>
> I guess we could do something similar for PNG with gray, presumably we 
> would get a two plane image (with gray as one plane) the alpha would 
> map to _deltaA as before. Then later we would need to handle two plane 
> images as well as the standard three plane ones. What mode do your 
> images have when opened in PIL/Pillow?
>
>>
>> On 23-05-17 18:37, Tim Roberts wrote:
>>> Arkadi Colson wrote:
>>>> Does anybody know if it's possible to use tranparent png images 
>>>> with the
>>>> code below:
>>>>
>>>> self.data[x][y] = Paragraph(
>>>>                               '<img src="' + filename + '"
>>>> valign="middle"/>', style=self.style_def)
>>> Wouldn't it have been quicker just to try it?
>>>
>>> Although I don't know the answer, I will point out that transparency 
>>> has
>>> always been a tricky issue with PostScript and, by extension, PDF.  
>>> Both
>>> standards were designed with paper and printing in mind, where
>>> transparency does not exist.  Most professional print shops will not
>>> accept PDF files with embedded transparency, because it's not clear 
>>> what
>>> that means.
>>>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 1908 bytes
Desc: not available
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20170524/4fcbcb3f/attachment.png>


More information about the reportlab-users mailing list