1. currentcmykcolor

Returns current color as CMYK values.

1.1. Syntax

– currentcmykcolor → cyan magenta yellow black

1.2. Stack Effects

Table 1. Before
Level Object

(empty)

Table 2. After
Level Object

3

cyan (0.0 to 1.0)

2

magenta (0.0 to 1.0)

1

yellow (0.0 to 1.0)

0

black (0.0 to 1.0)

1.3. Description

currentcmykcolor returns the current color in the graphics state according to the cyan-magenta-yellow-black color space.

  • If the current color space is DeviceCMYK, currentcmykcolor returns the color values most recently specified by setcmykcolor or [setcolor].

  • If the current color space is DeviceRGB or DeviceGray, currentcmykcolor converts the current color to CMYK.

  • For any other color space, currentcmykcolor returns 0.0 0.0 0.0 1.0 (black).

Each returned value is in the range 0.0 (no ink) to 1.0 (full ink coverage).

1.4. PostScript Level

Level 2 and later

1.5. Examples

Querying current CMYK color
0 1 1 0 setcmykcolor  % Cyan
currentcmykcolor
% Stack: 0.0 1.0 1.0 0.0
Saving and restoring color
currentcmykcolor            % Save current
/black exch def
/yellow exch def
/magenta exch def
/cyan exch def

1 0 0 0 setcmykcolor        % Change to cyan
drawShape

cyan magenta yellow black setcmykcolor  % Restore
Converting from RGB
1 0 0 setrgbcolor  % Red
currentcmykcolor
% Stack: 0.0 1.0 1.0 0.0 (approximately)
Adjusting black component
currentcmykcolor
0.5 add                % Increase black
4 1 roll               % Reorder
setcmykcolor

1.6. Common Use Cases

/SaveCMYK {
  currentcmykcolor
  /savedBlack exch def
  /savedYellow exch def
  /savedMagenta exch def
  /savedCyan exch def
} def

/RestoreCMYK {
  savedCyan savedMagenta savedYellow savedBlack
  setcmykcolor
} def

1.6.2. Undercolor Removal Adjustment

/ApplyUCR {
  currentcmykcolor
  % Get minimum of CMY
  3 copy
  2 copy lt { exch } if pop
  2 copy lt { exch } if pop
  % Add to black, reduce CMY
  dup 4 1 roll add
  4 1 roll exch 3 -1 roll sub
  3 1 roll exch 3 -1 roll sub
  3 1 roll exch 3 -1 roll sub
  3 1 roll
  setcmykcolor
} def

1.6.3. Rich Black Creation

/SetRichBlack {
  % Create rich black (C+M+Y+K)
  currentcmykcolor
  pop  % Remove old black
  0.5  % New black value
  exch 0.3 add  % Add cyan
  exch 0.3 add  % Add magenta
  exch 0.3 add  % Add yellow
  3 -1 roll
  setcmykcolor
} def

1.6.4. Spot Color Simulation

/SimulateSpotColor {
  % Convert current color and ensure no RGB
  currentcmykcolor
  4 array astore /cmykColor exch def
  cmykColor aload pop setcmykcolor
} def

1.7. Common Pitfalls

Color Space Conversion - RGB to CMYK conversion is not exact.
1 0 0 setrgbcolor      % Pure red in RGB
currentcmykcolor       % ~0 1 1 0 in CMYK
setcmykcolor
currentrgbcolor        % May not be exactly 1 0 0
Returns Black for Unknown Spaces - Pattern and other spaces return 0 0 0 1.
/Pattern setcolorspace
myPattern setcolor
currentcmykcolor        % Returns 0 0 0 1
Stack Order - CMYK order: cyan at level 3, black at level 0.
currentcmykcolor
% Stack (bottom to top): cyan magenta yellow black
% Pop order: black, yellow, magenta, cyan
Level 2 Only - Not available in Level 1 interpreters.
/languagelevel where {
  pop languagelevel 2 ge {
    currentcmykcolor
  } {
    % Level 1 - no CMYK support
  } ifelse
} if
Use Array for Storage - Simplifies CMYK color management.
[ currentcmykcolor ] /myColor exch def
myColor aload pop setcmykcolor

1.8. Error Conditions

Error Condition

[stackoverflow]

Fewer than 4 free stack positions

[undefined]

Level 1 interpreter (operator not defined)

1.9. Implementation Notes

  • Level 2 operator

  • Fast query operation

  • No modification to graphics state

  • Values always in range 0.0 to 1.0

  • Conversion algorithms device-dependent

  • Ideal for print production workflows

1.10. Color Conversion

When converting from other color spaces:

Gray to CMYK
cyan = magenta = yellow = 0.0
black = 1 - grayValue
RGB to CMYK (simplified)
cyan    = 1 - red
magenta = 1 - green
yellow  = 1 - blue
black   = min(cyan, magenta, yellow)
cyan    = cyan - black
magenta = magenta - black
yellow  = yellow - black
Other Spaces
cyan = magenta = yellow = 0.0
black = 1.0

1.11. CMYK Color Model

The CMYK color model is subtractive:

Cyan    + Magenta = Blue
Cyan    + Yellow  = Green
Magenta + Yellow  = Red
C + M + Y         = Dark gray
C + M + Y + K     = Rich black
No components     = White (paper)

1.12. See Also


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.