TCPDF图像宽高比问题

I have an issue with TCPDF Image inserting.

enter image description here

Here's the code i'm using :

$this->Image($this->data['logo'], PDF_MARGIN_LEFT, 5, 60, 20, '', '', 'M', true);

I've set the resize at true, but the TCPDF library do not respect image ratio.

How can I force preserving image ratio ?

For information I'm using TCPDF 6.2.8 (2015-04-29).

Thanks for your support, David.

Here's the solution I found :

    if ('' != $this->data['logo'] && is_file($this->data['logo'])) {
        // select only one constraint : height or width. 60x20 image emplacement => ratio = 3 (60/20)
        list($image_w, $image_h) = getimagesize($this->data['logo']);
        if (3 > $image_w / $image_h) list($w, $h) = array(0, 20);
        else list($w, $h) = array(60, 0);

        $this->Image($this->data['logo'], PDF_MARGIN_LEFT, 5, $w, $h, '', '', 'M');
    }

I've found the image emplacement ratio (60/20=3), I compared it to the image ratio and I choose between set the width or the heigh.

Thanks to JamesG to help me to find my solution.

David.

If you want to preserve the image's aspect ratio, just set either the width parameter or the height parameter to zero.

In your example I can see that you've set the width to 60 and the height to 20. Try setting the width to 0 and leaving the height at 20 - I think you will get a good result. And you can probably leave off the resize parameter too.