[reportlab-users] Reportlab and PIL images
robin at reportlab.com
Tue Apr 26 12:16:24 EDT 2005
Sam Hunter wrote:
> Hi, I'm just getting started with Reportlab, and I've run into a
> problem. I am trying to write an application which stores images in a
> pdf for possible later printing.
> I would like to be able to resize these images without distortion (same
> HxW ratio) so that they fit on a page. To do this I need height and
> width before I write the image to the canvas.
> What I would like to do, is use the PIL image to load and resize, then
> stick the PIL image onto the canvas like this:
..... you can't feed straight PIL images into drawImage.
Try creating an ImageReader object
from reportlab.lib.utils import ImageReader
im = ImageReader(filename)
You can get the size using im.getSize().
Decide whether you want to do PIL resizing or let PDF do it. If you want PIL to
do stuff create an image with PIL manipulate it and then create a temporary file
or StringIO containing the image and pass that to ImageReader.
If you allow acrobat to resize then just specify width and height to the
More information about the reportlab-users