Convert RGB to CMYK

Convert an RGB or hexadecimal input to device-cmyk() and CMYK channels.

Parse any sRGB input and convert it to PHPColor's CMYK representation:

use PhpColor\Color\Color;

$cmyk = Color::parse('rgb(59 130 246)')->to('cmyk');

echo $cmyk->toCss();
// device-cmyk(76.01626% 47.154472% 0% 3.529412%)

$channels = $cmyk->getChannels();
// c, m, y, and k are normalized from 0 to 1
use PhpColor\Color\Color; $cmyk = Color::parse('rgb(59 130 246)')->to('cmyk'); echo $cmyk->toCss(); // device-cmyk(76.01626% 47.154472% 0% 3.529412%) $channels = $cmyk->getChannels(); // c, m, y, and k are normalized from 0 to 1

This is a mathematical device-CMYK conversion, not a printer profile or color-managed proof. Production print output still needs the ICC profile and conversion rules supplied by the printer.