Photo layout

stephen at theboulets.net stephen at theboulets.net
Mon Jun 27 20:02:18 EDT 2005


Thanks! This works well -- I was letting myself be too intimidated with
reportlab before looking at the documentation, but it was really not
hard at all. I think I figured out how to do landscape mode too.

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter

def insertPicture(c):
....c.drawInlineImage("geese1.jpg",100,100,200,150)

width, height = letter
letter = height, width # change to landscape
c = canvas.Canvas("picture.pdf",pagesize=letter)
insertPicture(c)
c.showPage()
c.save()

Larry Bates wrote:
> You can use Python Imaging Library (PIL) and ReportLab to resize and
> place the photos on a page quite easily.  Actually ReportLab calls
> PIL automatically to resize the photos when you call .drawInlineImage
> method of the canvas object with the proper width and height arguments.
>
> To get ReportLab go to: http://www.reportlab.org
>
> Note: I'm assuming the photos are in .JPG, .TIF or some format that
> PIL can recognize.  If they are in some proprietary RAW format you
> will need to convert them first.
>
> -Larry Bates
>
> Stephen Boulet wrote:
> > Is there a python solution that someone could recommend for the following:
> >
> > I'd like to take a directory of photos and create a pdf document with
> > four photos sized to fit on each (landscape) page.
> > 
> > Thanks.
> > 
> > Stephen




More information about the Python-list mailing list