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

Fix rgb to cmyk division by zero bug #82

Merged
merged 1 commit into from
Dec 18, 2022

Conversation

stefanriehl
Copy link

There was a bug when converting rgb(0,0,0) to Cmyk

$rgb = (new Rgb(0,0,0))->toCmyk();
PHP Error: Division by zero in .../vendor/spatie/color/src/Convert.php on line 67

This error occurs when $keyNeg will be 0.

Another bug is when converting i.e. rgb(27,12,98) to Cmyk.

$rgb = (new Rgb(27,12,98))->toCmyk();
Spatie\Color\Exceptions\InvalidColorValue with message 'Cmyk value yellow must be a number between 0 and 1'

I fixed both bugs and added tests.

@freekmurze freekmurze merged commit 4973926 into spatie:main Dec 18, 2022
@freekmurze
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants