Forum


Replies: 2   Views: 2250
Image sized at 127 dpi?
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 cmoller  · 26-03-2019 - 20:52

We are generating Word documents from HTML using embedHTML and the images are being sized smaller than expected. For example, for an image that is 99 x 75px at 72 dpi the image size in the generated document the image size is 1.98cm x 1.5cm. If we specify the size of the image as 78 x 60px via the img height & width attributes the image size in the generated document is 1.56 cm x 1.2 cm. It looks like the images are being sized as 127 dpi. Is that the case? And why would that be if the image itself is 72 dpi? If we can rely on images always being sized at 127 dpi we can scale them up manually before passing to embedHTML but we don't want to make that assumption if something different is happening.

Posted by admin  · 27-03-2019 - 08:28

Hello,

Images are not forced to 127 dpi. Using embedHTML, the image size is calculated using getimagesize from PHP or width/height properties/styles if set. The final size is calculated from the previous values multiplicated by 7200 EMUs (on https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/ you can read more information about EMUs). For further information, in the file HTML2WordML.php you can read the internal method used to calculate image sizes: getImageDimensions method.

We recommend you to normalize all images (resolution) and apply width/height sizes based on the needed output. Or use the addImage method that includes more options (height, width, dpi, scaling...). You can also add text placeholders in your HTML to set the image locations and then replace them by images as WordFragments created with addImage.

Regards.

Posted by cmoller  · 27-03-2019 - 15:19

Thank-you for your prompt & detailed explanation. This is very helpful!