CMYK Formula Editor is a free online tool to edit images using math formulas on the CMYK inks. Printers make every color with four inks: cyan, magenta, yellow and black (K). Here each pixel of your image is split into these four inks, from 0% to 100%, and you write a formula for the new amount of each ink, plus the transparency (alpha).
Thinking in inks makes some edits very simple: k * 0.5 lifts the shadows without washing out their colors, k = 0 shows the image without the black plate, y + 15 adds yellow ink everywhere, and setting three inks to 0 shows a single color separation. With the position of the pixel, the formulas can even turn the image into halftone dots, like a printed magazine.
The formulas are evaluated by your graphics card (with WebGL2), so the image updates while you type, even for large photos. Everything runs in your browser: your image is never uploaded to a server. You can also edit images with formulas for the red, green and blue channels, or for the hue, saturation and lightness.
Click on any example to apply its formulas to your image (or to the sample image, if you haven't opened one), and edit them.
| C | c |
| M | m |
| Y | y |
| K | k * 0.5 |
| A | a |
| C | c |
| M | m |
| Y | y |
| K | 0 |
| A | a |
| C | c |
| M | 0 |
| Y | 0 |
| K | 0 |
| A | a |
| C | 0 |
| M | m |
| Y | 0 |
| K | 0 |
| A | a |
| C | 0 |
| M | 0 |
| Y | y |
| K | 0 |
| A | a |
| C | 0 |
| M | 0 |
| Y | 0 |
| K | k |
| A | a |
| C | c |
| M | m + 6 |
| Y | y + 15 |
| K | k |
| A | a |
| C | c * 0.55 |
| M | m * 0.6 |
| Y | y * 0.6 + 12 |
| K | k * 0.7 |
| A | a |
| C | 0 |
| M | max(c, m, y) |
| Y | 0 |
| K | k |
| A | a |
| C | round(c / 50) * 50 |
| M | round(m / 50) * 50 |
| Y | round(y / 50) * 50 |
| K | k > 75 ? 100 : 0 |
| A | a |
| C | (cos(250 * (px * 0.966 + py * 0.259) / width) + cos(250 * (py * 0.966 - px * 0.259) / width)) / 2 > 1 - c / 50 ? 100 : 0 |
| M | (cos(250 * (px * 0.259 + py * 0.966) / width) + cos(250 * (py * 0.259 - px * 0.966) / width)) / 2 > 1 - m / 50 ? 100 : 0 |
| Y | (cos(250 * px / width) + cos(250 * py / width)) / 2 > 1 - y / 50 ? 100 : 0 |
| K | (cos(177 * (px + py) / width) + cos(177 * (py - px) / width)) / 2 > 1 - k / 50 ? 100 : 0 |
| A | a |
| C | 0 |
| M | 0 |
| Y | 0 |
| K | (cos(177 * (px + py) / width) + cos(177 * (py - px) / width)) / 2 > (0.299 * r + 0.587 * g + 0.114 * b) / 127.5 - 1 ? 100 : 0 |
| A | a |
k * 0.5 or y + 10. The image updates while you type, and errors are shown below the formula.CMYK is the way printers make colors: they put dots of four inks on white paper. Each ink absorbs part of the light, so the more ink, the darker the color (screens do the opposite, adding red, green and blue light).
This tool converts each pixel with the simple formulas used by most websites: the black ink is the darkness of the strongest of the red, green and blue channels, k = 100 - max(r, g, b) / 2.55, and the other inks make the rest of the color. So a pure black pixel has only black ink, and a pure color like red has no black at all. The result is converted back to red, green and blue to be shown on the screen:
red = 255 × (1 - C / 100) × (1 - K / 100)green = 255 × (1 - M / 100) × (1 - K / 100)blue = 255 × (1 - Y / 100) × (1 - K / 100)A printing press prints the four inks one after the other, each with its own plate. Setting three inks to 0 shows what a single plate prints, like the "Cyan plate" and "Black plate" examples above. A separation shown this way is a preview made with the simple formulas above, not the exact plates of a professional printer, which depend on the paper, the inks and the press.
The formulas can use these values of the original pixel:
| Variable | Description |
|---|---|
c, m, y, k | The cyan, magenta, yellow and black ink of the original pixel, from 0 to 100. In this tool y is the yellow ink, not the vertical position. |
r, g, b | The red, green and blue values of the original pixel, from 0 to 255. |
a | The alpha (opacity) of the original pixel, from 0 (transparent) to 255 (opaque). |
h, s, l | The hue (0 to 360), saturation (0 to 100) and lightness (0 to 100) of the original pixel, to change only some colors: abs(h - 120) < 40 ? c : 0 keeps the cyan ink only in the greens. |
px, py | The position of the pixel: px from 0 (left) to the width minus 1, and py from 0 (top) to the height minus 1. |
width, height | The size of the image, in pixels. px / width goes from 0 on the left to 1 on the right. |
You can also use the constants PI (3.14159...) and E (2.71828...), with or without "Math.".
| Field | Description |
|---|---|
| C (cyan) | The new amount of cyan ink. It should give a value between 0 and 100. |
| M (magenta) | The new amount of magenta ink, from 0 to 100. |
| Y (yellow) | The new amount of yellow ink, from 0 to 100. |
| K (black) | The new amount of black ink, from 0 to 100. Less black ink makes the pixel lighter without changing its hue. |
| A (alpha) | The new alpha of the pixel, from 0 (transparent) to 255 (opaque). Values outside this range are clamped. Use a to keep the original transparency. |
When the formula of an ink gives a value outside the range from 0 to 100, the value is adjusted:
| Option | Description |
|---|---|
| Clamp | Values lower than 0 become 0, and values greater than 100 become 100. This is the best option for most edits, like y + 15. |
| Bounce | The value keeps "bouncing" between 0 and 100: 110 becomes 90, 150 becomes 50, and 210 becomes 10. |
| Remainder | The value starts over from 0 when it passes 100: 110 becomes 10 and 150 becomes 50. Values between 0 and 100 are kept, so a full ink stays full. |
The formulas use the syntax of Javascript expressions.
| Operator | Description | Example |
|---|---|---|
+ - * / | Addition, subtraction, multiplication and division. Multiplication always needs the *: write 2 * k, not 2k. | k * 0.5 |
** | Power. | 100 * (k / 100) ** 2 |
% | Remainder of the division. | (px + py) % 20 < 10 ? c : 0 |
< > <= >= == != | Comparisons. They give 1 when true and 0 when false. | (k > 50) * 100 |
condition ? a : b | Gives the first value when the condition is true (not zero) and the second value otherwise. | k > 75 ? 100 : 0 |
&& || ! | Logical AND, OR and NOT, to combine conditions. | m > 50 && y > 50 ? 0 : c |
& | ^ ~ << >> >>> | Bitwise AND, OR, XOR, NOT and shifts. The values are converted to whole numbers first. | (px ^ py) % 100 |
The functions of the Javascript Math object can be used with or without "Math.": Math.sin(px) and sin(px) are the same. The angles are in radians.
| Function | Description | Example |
|---|---|---|
min(a, b, ...), max(a, b, ...) | The smallest and the largest of the values. | max(c, m, y) |
abs(a), sign(a) | Absolute value, and the sign (-1, 0 or 1). abs(h - 120) < 30 is true for the hues near 120. | abs(h - 120) < 30 ? 0 : c |
floor(a), ceil(a), round(a), trunc(a) | Round down, round up, round to the nearest whole number, and remove the decimals. | round(c / 50) * 50 |
sin(a), cos(a), tan(a) | Sine, cosine and tangent. Also asin, acos, atan and atan2(y, x). Two cosines make the grid of dots of the halftone examples. | m + 20 * sin(py / 15) |
hypot(a, b, ...) | The square root of the sum of the squares: hypot(px - width / 2, py - height / 2) is the distance from the center of the image. | k + hypot(px - width / 2, py - height / 2) / 8 |
sqrt(a), cbrt(a), pow(a, b) | Square root, cube root and power. | 10 * sqrt(k * 10) |
exp(a), log(a), log2(a), log10(a) | Exponential and logarithms. Also expm1(a) and log1p(a). | log1p(k) * 21.6 |
sinh(a), cosh(a), tanh(a), asinh(a), acosh(a), atanh(a) | Hyperbolic functions and their inverses. tanh makes smooth S-curves. | 50 + 50 * tanh((k - 50) / 25) |
random() | A random number between 0 and 1, different for every pixel. The same image always gets the same numbers. | k + (random() - 0.5) * 10 |
No. The tool shows the inks with the simple formulas above, and the downloaded image is a normal PNG image, with red, green and blue values. Professional software like Photoshop converts images to CMYK with a color profile (like FOGRA39 or US Web Coated SWOP), which describes the inks and the paper of a real press and gives different values. Use this tool for creative edits and to understand the inks, and ask your printer how they want the file.
Why is "y" the yellow ink and not the vertical position?Because the four inks are called C, M, Y and K. The position of the pixel is px (horizontal) and py (vertical). A formula copied from the RGB Formula Editor that uses x gives an error here: replace x with px and y with py.
With the simple formulas, all the darkness goes to the black ink, so black is 100% K and nothing else. Printers often add other inks under the black to make it deeper, which is called "rich black" (for example k > 90 ? max(c, 60) : c for the cyan). On the screen it makes no difference, because 100% black ink is already pure black.
In a very dark pixel, the cyan, magenta and yellow inks are computed from tiny differences between the red, green and blue values, which are often just compression noise of a JPEG photo. Removing the black ink makes those inks visible. Reduce the black less (k * 0.7), or keep the black of the darkest pixels: k > 85 ? k : k * 0.5.
Yes, every CMYK edit can be written with red, green and blue formulas, because the inks are computed from them. But some edits are much simpler with inks: k * 0.5 here would be a long formula for each channel in RGB. Some other edits are the same in both: swapping the cyan and the magenta is the same as swapping the red and the green.
Four inks describe a color with four numbers, but a color on the screen only needs three, so different combinations of inks give the same color. For example, 100 - (100 - c) * (100 - k) / 100 for the cyan (and the same for the magenta and the yellow) with 0 for the black gives exactly the original image, printed without black ink. On a real press the result would be different, because real inks are not perfect.
Printers limit the sum of the four inks (for example to 300%), because too much ink doesn't dry. To scale down the inks of the pixels above a limit of 200%, multiply each ink by min(1, 200 / (c + m + y + k)), for example c * min(1, 200 / (c + m + y + k)) for the cyan.
The formulas are computed by your graphics card, with 32-bit numbers. For colors this makes no visible difference, but very large values (for example sin(px * py * 1000)) lose precision.
The size of the image is limited by your graphics card, usually to 8192 or 16384 pixels on each side. Make it smaller with Resize image first.
What is WebGL2?WebGL2 is the technology that lets websites use your graphics card. All modern browsers support it. If the image doesn't appear, check that hardware acceleration is enabled in the settings of your browser.
Is my image uploaded to a server?No. Your image is read and edited by your own browser, and it never leaves your computer.
