Skip to content

Commit

Permalink
Fix division by zero in Rgb toCmyk method
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekwaah committed Apr 18, 2024
1 parent b0105c7 commit fc5e9d3
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 fc5e9d3

Please sign in to comment.