Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divide by zero #112

Open
ambroisemaupate opened this issue Jun 29, 2016 · 1 comment
Open

Divide by zero #112

ambroisemaupate opened this issue Jun 29, 2016 · 1 comment

Comments

@ambroisemaupate
Copy link
Contributor

A divide by zero is occuring in Util.php on line 59 in calculateDependantSizes method.

When ratio is not set or null or 0.

Could we throw an exception when this method parameters does not match requirements?

Moreover $ratio can be zero in ImageConvertAttributesFormatter line 40
$originalRatio = $originalHeight ? $originalWidth/$originalHeight : 0;

@millejano
Copy link

millejano commented Jan 12, 2017

There is also a "Division by zero" Warning if using a combination of keep-ration and ignore-error for a non existing image.

An example:
styles.xml
<img class="image" height="7.5cm" width="10cm" ignore-error="true" keep-ratio="keep-ratio" />

image.pdf.twig
<img class="image" src="{{ image.url }}" />

The images doesn't exists.

Warning Message: Division by zero
see psliwa/php-pdf/lib/PHPPdf/Core/Node/Image.php at line 97
$sourceRatio = $sourceImage->getOriginalHeight() / $sourceImage->getOriginalWidth();

Quickfix for line 94
before:
if($keepRatio
after:
if($keepRatio && $sourceImage->getOriginalWidth())

Can you fix this booth issues in a new version, pls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants