diff --git a/lib/Common/PerspectiveTransform.php b/lib/Common/PerspectiveTransform.php index a3a0b97..5030d66 100644 --- a/lib/Common/PerspectiveTransform.php +++ b/lib/Common/PerspectiveTransform.php @@ -112,6 +112,9 @@ public static function squareToQuadrilateral( $dy1 = $y1 - $y2; $dy2 = $y3 - $y2; $denominator = $dx1 * $dy2 - $dx2 * $dy1; + if ((int)$denominator === 0) { + throw new \Exception('Cannot divide by 0, reduce error correction level and try again'); + } $a13 = ($dx3 * $dy2 - $dx2 * $dy3) / $denominator; $a23 = ($dx1 * $dy3 - $dx3 * $dy1) / $denominator;