Cyan, magenta, yellow and a black key, one component per process plate. This is the colour space a press sheet is specified in and the alternate space most spot colours fall back to. The conversion from RGB is exact arithmetic and round-trips at 8-bit precision.
Model
| Item | Value |
|---|---|
| Type string | CMYK |
| Enum case | ColorModelType::Cmyk |
| Class | \Com\Tecnick\Color\Model\Cmyk |
| PDF colour space | DeviceCMYK |
| Notations | cmyk(), cmyka(), ["CMYK",c,m,y,k] |
cmyk() and cmyka() are notations of this library, not CSS functions.
Components
| Component | Key | Range | Out of range |
|---|---|---|---|
| Cyan | cyan | 0.0 to 1.0 | clamped |
| Magenta | magenta | 0.0 to 1.0 | clamped |
| Yellow | yellow | 0.0 to 1.0 | clamped |
| Key (black) | key | 0.0 to 1.0 | clamped |
| Alpha | alpha | 0.0 to 1.0, default 1.0 | clamped |
Construction
<?php
require_once __DIR__ . '/vendor/autoload.php';
$cmyk = new \Com\Tecnick\Color\Model\Cmyk([
'cyan' => 2 / 3,
'magenta' => 1 / 3,
'yellow' => 0.0,
'key' => 0.4,
]);
echo $cmyk->getCssColor(), "\n";
echo $cmyk->getPdfColor();
echo $cmyk->getRgbHexColor(), "\n";
cmyk(66.6667%,33.3333%,0%,40%)
0.666667 0.333333 0.000000 0.400000 k
#336699
Output
Every accessor, against #336699:
| Call | Result |
|---|---|
getCssColor() | cmyk(66.6667%,33.3333%,0%,40%) |
getRgbHexColor() | #336699 |
getRgbaHexColor() | #336699ff |
getComponentsString() | 0.666667 0.333333 0.000000 0.400000 |
getPdfColor() | 0.666667 0.333333 0.000000 0.400000 k |
getPdfColor(true) | 0.666667 0.333333 0.000000 0.400000 K |
getJsPdfColor() | ["CMYK",0.666667,0.333333,0.000000,0.400000] |
getArray() | ['C' => 0.6666666666666667, 'M' => 0.33333333333333326, 'Y' => 0.0, 'K' => 0.4, 'A' => 1.0] |
getNormalizedArray(255) | ['C' => 170.0, 'M' => 85.0, 'Y' => 0.0, 'K' => 102.0, 'A' => 1.0] |
getPDFacArray() | [0.6666666666666667, 0.33333333333333326, 0.0, 0.4] |
getNormalizedArray(255) scales all four components to 255. Ink coverage is normally expressed in percent, which getCssColor() emits.
Key Extraction
The conversion complements the three RGB channels and pulls the common minimum out into the key component. Full black is the special case: it comes out as cmyk(0%,0%,0%,100%) rather than as four full components.
$web = new \Com\Tecnick\Color\Web();
foreach (['#000000', '#333333', '#ff0000', '#336699'] as $hex) {
$cmyk = \Com\Tecnick\Color\Model::create('CMYK', $web->getColorObj($hex)->toCmykArray());
printf("%-9s %s\n", $hex, $cmyk->getCssColor());
}
#000000 cmyk(0%,0%,0%,100%)
#333333 cmyk(0%,0%,0%,80%)
#ff0000 cmyk(0%,100%,100%,0%)
#336699 cmyk(66.6667%,33.3333%,0%,40%)
What The Conversion Does
toCmykArray() complements the three RGB channels, extracts their common minimum as the key and rescales the remainder. No profile, lookup table or configuration is involved, and the result returns to its original bytes: all 150 named colours round-trip through CMYK at 8-bit precision, as Conversions measures.
This is the conversion behind the k operator on PDF Output and behind the CMYK equivalent stored for a spot colour. Black generation, undercolour removal and a total ink limit come from an ICC profile: take those values from the profile in use and hold them as CMYK from the start.
A DeviceCMYK colour in a PDF/A document is only valid when the output intent is a CMYK profile. tc-lib-pdf reports the mismatch through getWarnings(); see /docs/standards/.
See Also
- tc-lib-color : the library overview.
- Colour Models : the five side by side.
- Spot Colours : CMYK as the alternate space of a separation.
- CIE Lab : the device-independent alternative.
- API reference : the generated class documentation.