Thursday 15 July 2010

python - How do i set the max size for an image in Reportlab, without rescaling? -


I am trying to generate a PDF using Reportlab. It is acceptable to be easy, I have a function whose picture below and I add it to the document.

  def create_logo (bsolute_path): image = image (absolute_path) image.drawHeight = 1 * inch image.drawWidth = 2 * inch return [image]   

It works, but as I want to do it my problem is that it saves my image as if I have an image of 3000px (width) x 1000px (height) in which there is 1 to 3 scale, then I Find a reshaped image in PDF: 1 to 2.

What I want to just specify is to specify the maximum width and height and report lab Give shape (do not rearrange it), if the image is too large.

Can this be done in the report or should I do it myself?

Thank you!

You can set preserveAspectRatio = True . Then the ratio should be 1: 3. drawImage (image, x, y, width = none, height = none, mask = none, preserveApectRatio = true, anchor = 'c')



No comments:

Post a Comment