Please bookmark this page to avoid losing your image tool!

RGB To CMYK Color Converter

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
function processImage(originalImg, channel = "All", mode = "Color") {
    const w = originalImg.width;
    const h = originalImg.height;
    
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');
    
    if (channel === "All") {
        canvas.width = w * 2;
        canvas.height = h * 2;
    } else {
        canvas.width = w;
        canvas.height = h;
    }

    // Draw the image on a white background to simulate paper and handle transparency
    const tempCanvas = document.createElement('canvas');
    tempCanvas.width = w;
    tempCanvas.height = h;
    const tempCtx = tempCanvas.getContext('2d');
    
    tempCtx.fillStyle = '#FFFFFF';
    tempCtx.fillRect(0, 0, w, h);
    tempCtx.drawImage(originalImg, 0, 0);
    
    const imgData = tempCtx.getImageData(0, 0, w, h);
    const data = imgData.data;

    // Helper to calculate CMYK values and generate layer image data
    const createLayer = (ch) => {
        const layerData = new ImageData(w, h);
        for (let i = 0; i < data.length; i += 4) {
            let r = data[i] / 255;
            let g = data[i + 1] / 255;
            let b = data[i + 2] / 255;

            // Simple RGB to CMYK formula
            let k = 1 - Math.max(r, g, b);
            let c = k === 1 ? 0 : (1 - r - k) / (1 - k);
            let m = k === 1 ? 0 : (1 - g - k) / (1 - k);
            let y = k === 1 ? 0 : (1 - b - k) / (1 - k);

            layerData.data[i + 3] = 255; // Output is always fully opaque

            if (mode === "Grayscale") {
                let v = 255;
                if (ch === "Cyan") v = 255 * (1 - c);
                else if (ch === "Magenta") v = 255 * (1 - m);
                else if (ch === "Yellow") v = 255 * (1 - y);
                else if (ch === "Black") v = 255 * (1 - k);
                
                layerData.data[i] = v;
                layerData.data[i + 1] = v;
                layerData.data[i + 2] = v;
            } else {
                if (ch === "Cyan") {
                    layerData.data[i] = 255 * (1 - c); // Red is absorbed by Cyan
                    layerData.data[i + 1] = 255;
                    layerData.data[i + 2] = 255;
                } else if (ch === "Magenta") {
                    layerData.data[i] = 255;
                    layerData.data[i + 1] = 255 * (1 - m); // Green is absorbed by Magenta
                    layerData.data[i + 2] = 255;
                } else if (ch === "Yellow") {
                    layerData.data[i] = 255;
                    layerData.data[i + 1] = 255;
                    layerData.data[i + 2] = 255 * (1 - y); // Blue is absorbed by Yellow
                } else if (ch === "Black") {
                    layerData.data[i] = 255 * (1 - k); // All light is absorbed by Black
                    layerData.data[i + 1] = 255 * (1 - k);
                    layerData.data[i + 2] = 255 * (1 - k);
                }
            }
        }
        return layerData;
    };

    const drawLayer = (ch, dx, dy) => {
        const layer = createLayer(ch);
        const tCanvas = document.createElement('canvas');
        tCanvas.width = w;
        tCanvas.height = h;
        tCanvas.getContext('2d').putImageData(layer, 0, 0);
        ctx.drawImage(tCanvas, dx, dy);
        
        // Add labels if we are displaying all channels inside a grid
        if (channel === "All") {
            ctx.fillStyle = "rgba(255, 255, 255, 0.85)";
            ctx.fillRect(dx + 5, dy + 5, 90, 28);
            ctx.fillStyle = "#000000";
            ctx.font = "bold 16px sans-serif";
            ctx.fillText(ch, dx + 12, dy + 25);
            
            // Draw a subtle border around the quadrants
            ctx.strokeStyle = "#CCCCCC";
            ctx.lineWidth = 1;
            ctx.strokeRect(dx, dy, w, h);
        }
    };

    if (channel !== "All") {
        drawLayer(channel, 0, 0);
    } else {
        // Draw 2x2 multi-channel grid
        drawLayer("Cyan", 0, 0);
        drawLayer("Magenta", w, 0);
        drawLayer("Yellow", 0, h);
        drawLayer("Black", w, h);
    }

    return canvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

This tool converts images from the RGB color model to the CMYK color model, which is essential for print media preparation. It allows users to visualize individual color channels—Cyan, Magenta, Yellow, and Black—either as separate color layers or as a grayscale representation. This is particularly useful for graphic designers and print professionals who need to inspect how an image will decompose into ink layers for professional printing processes.

Leave a Reply

Your email address will not be published. Required fields are marked *