Forum


Replies: 2   Views: 2970
Add image size error
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 15-03-2017 - 10:12

Hello,

The problem is that the images you are adding don't have the same dpi. So as you are not forcing a dpi, phpdocx uses the dpi from the image.

This image:

https://dev-or.s3.amazonaws.com/dev/Slide/9379/iconlist.jpg?1331844575

has 96 dpi. And this is a PNG image, not JPG; we recommend you to use extensions with the same mime types than images.

And this image:

https://dev-or.s3.amazonaws.com/dev/Slide/9380/iconlist.jpg?1331844575

has 72 dpi.

You can force the dpi value to get the exact image size, regardless the dpi of an image:

$image = array(
  'src' => 'image.jpg',
  'imageAlign' => 'center',
  'height' => 216,
  'width' => 288,
  'dpi' => 72,
);

$docx->addImage($image);

Regards.

P.S. we have changed your username to hide the email you wrote as username