Rapport d'aspect de l'image en utilisant Reportlab en Python

Je veux insérer une image dans un cadre. J'ai trouvé deux façons de le faire:

  1. drawImage(de soi, de l'image, x, y, width=Aucun, hauteur=None, masque=None, preserveAspectRatio=False, anchor='c')
  2. De l'Image(nom de fichier, largeur=Aucun, hauteur=None)

Ma question est: comment puis-je ajouter une image dans un cadre tout en conservant ses proportions?

from reportlab.lib.units import cm
from reportlab.pdfgen.canvas import Canvas
from reportlab.platypus import Frame, Image

c = Canvas('mydoc.pdf')
frame = Frame(1*cm, 1*cm, 19*cm, 10*cm, showBoundary=1)

"""
If I have a rectangular image, I will get a square image (aspect ration 
will change to 8x8 cm). The advantage here is that I use coordinates relative
to the frame.
"""
story = []
story.append(Image('myimage.png', width=8*cm, height=8*cm))
frame.addFromList(story, c)

"""
Aspect ration is preserved, but I can't use the frame's coordinates anymore.
"""
c.drawImage('myimage.png', 1*cm, 1*cm, width=8*cm, preserveAspectRatio=True)

c.save()

source d'informationauteur citn