Skip to content

Commit

Permalink
fix: prevent division by zero in Rgb toCmyk method (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekwaah authored Apr 18, 2024
1 parent b0105c7 commit 12338c9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Renderer/Color/Rgb.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public function toCmyk() : Cmyk
$y = 1 - ($this->blue / 255);
$k = min($c, $m, $y);

if ($k === 0) {
return new Cmyk(0, 0, 0, 0);
}

return new Cmyk(
(int) (100 * ($c - $k) / (1 - $k)),
(int) (100 * ($m - $k) / (1 - $k)),
Expand Down

0 comments on commit 12338c9

Please sign in to comment.