Re: Image within a table - Preserve Aspect Ratio

Maxim Danilov <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
hi Larissa.

If I have correctly understand, i think you break yours "IMAGE Aspect Ratio” in line:

maxIMAGE = platy.Image(maxIMAGE_path,2.2*inch, 2.2*inch)
Don’t matter that you have: jpeg 2x3 or png 100x1 you set it like img 2.2x2.2 always.

If you try to see in flowables.py <https://fossies.org/dox/reportlab-3.5.13/flowables_8py.html>,  class Image <https://fossies.org/dox/reportlab-3.5.13/classreportlab_1_1platypus_1_1flowables_1_1Image.html>(Flowable <https://fossies.org/dox/reportlab-3.5.13/classreportlab_1_1platypus_1_1flowables_1_1Flowable.html>):
def __init__ <https://fossies.org/dox/reportlab-3.5.13/classreportlab_1_1platypus_1_1flowables_1_1Image.html#a6e8d7de8469646f51b23cc9d37f9dca3>( … width=None, height=None, … )
You can give only one dimensions or don’t give nothing.
Image.draw() should calculate all himself.

But I always like to do a little more comfortable.
I override platy.Image. with a New_class
For my new class I give in init also max-height and max-width. it help me to transform Image before draw, how I want.



Mit freundlichen Grüßen,
DI Mag. Maxim Danilov

+43(681)207 447 76
[email protected]



> On 23.02.2019, at 07:39, [email protected] wrote:
> 
> maxIMAGE = platy.Image(maxIMAGE_path,2.2*inch, 2.2*inch)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.