I am trying to generate an pdf using Reportlab. It is acceptably easy. I have a function like the one below that returns the image and I just 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 not as I want it to. The problem I have is that it rescales my image. E.g. If i have an image 3000px(width) x 1000px (height) which has a scale 1 to 3, i get in the pdf a rescaled image: 1 to 2.
What i basically want is to just specify the maximum width and height and let reportlab resize it (not rescale it), if the image is too big.
Can this be done in Reportlab or should I do that myself?
Thanks!
I found this also :
Image aspect ratio using Reportlab in Python
but in the end i used this method :
def create_logo(absolute_path):
image = Image(absolute_path)
image._restrictSize(2 * inch, 1 * inch)