[reportlab-users] Loading transparent GIFs with shapes.Image

Marcel Tromp mtromp.docbook at gmail.com
Wed Nov 18 18:04:52 EST 2009

Target is pdf. However, I have not been using canvas in my scripts. So far I
have been grouping shapes (including images) in groups, which ultimately get
added to a Drawing, which get rendered to a pdf.

In this method, transparency does not work.

What is the benefit to use canvas instead beyond the image rendering?


On Thu, Nov 12, 2009 at 4:58 AM, Robin Becker <robin at reportlab.com> wrote:

> Marcel Tromp wrote:


>> Anyone? Is there anyway to have overlapping bitmap images that use

>> transparency to show the lower/earlier image?


>> I don't believe that shapes.Image supports any notion of transparency. Al

> of the reportlab graphs renderers depend explicitly on properties of the

> different back ends so it's fairly hard to support some of the more advanced

> concepts like overPrint and transparency.


> You don't say which back end is being used. If you want to put images onto

> a PDF document then the pdfgen canvas already supports bitmaps with RGBA and

> a transparent colour.


> If you're talking about the PM renderer then that's not done. The code is

> in renderPM.py


>> def drawImage(self, image):

>> if image.path and os.path.exists(image.path):

>> if type(image.path) is type(''):

>> im =

>> _getImage().open(image.path).convert('RGB')

>> else:

>> im = image.path.convert('RGB')

>> srcW, srcH = im.size

>> dstW, dstH = image.width, image.height

>> if dstW is None: dstW = srcW

>> if dstH is None: dstH = srcH

>> self._canvas._aapixbuf(

>> image.x, image.y, dstW, dstH,

>> im.tostring(), srcW, srcH, 3,

>> )




> so we would need to modify this.


> Effectively im is a PIL image and we mash it directly onto our internal RGB

> buffer using libart's function art_rgb_pixbuf_affine.


> Libart does have a function art_rgb_rgba_affine which could be used to mash

> an RGBA style image onto the RGB canvas. That would allow RGB + transparent

> colour or RGBA style sources to be used for the incoming image. Of course

> then we'd need to start looking at the Image processing for the other

> graphics renderers.

> --

> Robin Becker

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20091118/63c65df4/attachment.htm>

More information about the reportlab-users mailing list