[reportlab-users] PIL frombuffer question

Robin Becker robin at reportlab.com
Fri Mar 9 05:38:16 EST 2007


Paul Guse wrote:

> Well I partially answered my own question. I can get a pixel buffer to write to the canvas as an image with the following code:

>

> mode = 'RGB'

> img = PIL.Image.frombuffer (mode, (100,100), b, "raw", mode, 0, 1)

> img.fp = ""

>

> i = ImageReader (img)

> c.drawImage (i, 100, 100, 100, 100)

>

> If I don't set img.fp I get an attribute error. This draws the image to the pdf correctly.

> Anyways, this seems like a bit of a hack, and I'm sure there's a better way to do it. Also, it would be great to be able to create a platypus flowable out of a pixel buffer.

> Does anyone have any tips for doing this?

>

> Paul

>

.......

We're probably assuming something about how Pil images are used in the
ImageReader class. However, this must be a kind of strange way to do things. Why
draw into a pixel buffer when you can draw directly to the pdf?
--
Robin Becker


More information about the reportlab-users mailing list