Forum


Replies: 3   Views: 1240
Devision by zero in line 51
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 CarlEOgden  · 13-10-2020 - 07:13

Hi

I couldn't find any other posts stating this error, but when we try to create a docx, sometimes an image makes an exception:-

```
 

array:1 [
  "e" => Exception {#2290
    #message: "Division by zero"
    #code: 0
    #file: "/mnt/storage/standout/public_html/dev/public/phpdocx/classes/PhpdocxLogger.php"
    #line: 51
    trace: {
      /mnt/storage/standout/public_html/dev/public/phpdocx/classes/PhpdocxLogger.php:51 {
        PhpdocxLogger::logger($message, $level) …
        › if ($level == 'fatal') {    throw new Exception($message);}
      }

```

But all the values in the image are greater than zero, in fact they are ["Width"]=> int(2048) ["Height"]=> int(1366) and we  force the image width to be 295.

The code is:

```
$image_options = [
'height' => ($room_photograph->Height / $room_photograph->Width) * $image_width,
'src' => $room_photograph->MediaURL,
'imageAlign' => 'center',
'textWrap' => 0,
'width' => $image_width,
];

```

Any ideas on how to fix this issue?

Thanks in advance
Carl.