• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
9

Photoshop RGB to CMYK conversion error

New Here ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

Hello RGB-2-CMYK conversion team!
------------------------------------------------

I recently experienced some problems with conversion from standard PNG formats to CMYK:
* our image generation software can generate different image "modes" which are called "1" (single-bit b/w), "L" (we don't used it), "RGB", "RGBA" and "P"
* "P" stands for "Palette"-mode and enables huge reduction of size of image (>30%): even for the b/w-case, images are sensibly smaller than the "1"-mode
* "P" defines internal colours both for "RGA" and "RGBA"

-------
However, only the "1" mode was converted to the expected black. Pure RGB Black (0, 0, 0) seem not to match the expectations.
I do not know more details what black was expected, so I can not really help with that.

I suggest that in the future to directly being able to convert CMYK from P-mode PNG format.
TOPICS
iPadOS , macOS , Web , Windows

Views

160

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

You can convert to CMYK, but the result for the black value isn't what you expect?

 

Each CMYK profile characterizes a specific print process. Printing processes & inks & paper vary, and there is no such thing as a general universal "CMYK". There is only a range of CMYK profiles, and you need to know which one applies.

 

CMYK never gives you "full" black. CMYK is based on printing physical inks on physical paper. There is a total ink limit, and that defines the deepest possible black in print. Exceeding this limit gives smearing and drying problems on press. The ink limit is built into every CMYK profile.

 

In ISO Coated v2 300%, just to take one example, 0-0-0 black converts to 78-68-58-94. That's the deepest possible black in print. Convert that back to, say, Adobe RGB, and you get 5-4-7, not 0-0-0.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

@timo35133572mgip – Your "P" mode sounds like Indexed Colour mode in Photoshop.

 

All colour transforms using Edit > Convert to Profile (or Mode > CMYK)  generally use ICC colour management, so the RGB Indexed colour source values are converted through the PCS (Profile Connection Space) found in the destination ICC profile, which is generally Lab or XYZ based, then mapped to the CMYK values in the profile for the selected rendering intent table.

 

In other words, there is no direct mapping of values from source to destination. This is what a Device Link ICC profile does, it's a direct mapping of source to destination.

 

It is possible to manually create a direct mapping of the source data to the K channel of CMYK, using no CMY data via an action or script automation.

 

Otherwise, the legacy Custom CMYK colour conversion engine can convert to a Maximum Black GCR with 100% black generation (a dot gain or tonal value increase compensation curve will be applied so the destination data isn't linear compared to the source, which is generally a good thing). Modern ICC profile generation software is preferred to create such profiles today, however, this isn't as accessible for most users as the legacy Custom CMYK engine is, as this requires extra software and often hardware as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

Thanks, @Stephen_A_Marsh 

 

May I hire you for contractual work to create such script and consult on details? 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

@timo35133572mgip 

 

Can I assume that the "P" Indexed Colour mode is B&W or does it also contain colour? My comment regarding mapping to K only in CMYK was in the context of neutral black and white (shades of grey).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

The following script is provided without any guarantee or warranty – it may not be considered fit for purpose :]

 

 

/*
Map Neutral Indexed Colour to K of CMYK.jsx
v1.0 - 31st January 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-bugs/photoshop-rgb-to-cmyk-conversion-error/idc-p/14391441
Note: 
* This script is only intended for neutral indexed mode images
* No TVI/Dot Gain compensation has been applied, the image may print darker than expected!
*/

#target photoshop

if (app.activeDocument.mode === DocumentMode.INDEXEDCOLOR) {

    app.activeDocument.save();

    activeDocument.changeMode(ChangeMode.LAB);

    /* https://community.adobe.com/t5/bridge-discussions/script-to-find-colour-in-quot-black-amp-white-quot-jpgs/td-p/14141472 */
    var aCha = theHistProps(activeDocument.channels[1].histogram);
    var bCha = theHistProps(activeDocument.channels[2].histogram);
    // theMean = [0] | theMedian = [1] | theStandDev = [2]
    var theValue = (((aCha[2] + bCha[2]) / 2).toFixed(2));

    if (theValue == 0.00) {

        executeAction(stringIDToTypeID("revert"), undefined, DialogModes.NO);

        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;

        app.activeDocument.changeMode(ChangeMode.RGB);

        app.activeDocument.channels[1].duplicate();

        app.activeDocument.changeMode(ChangeMode.MULTICHANNEL);

        app.activeDocument.changeMode(ChangeMode.CMYK);

        var descriptor = new ActionDescriptor();
        var list = new ActionList();
        var list2 = new ActionList();
        var list3 = new ActionList();
        var list4 = new ActionList();
        var reference = new ActionReference();
        var reference2 = new ActionReference();
        var reference3 = new ActionReference();
        reference.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("cyan"));
        descriptor.putReference(stringIDToTypeID("channel"), reference);
        descriptor.putDouble(stringIDToTypeID("horizontal"), 0.000000);
        descriptor.putDouble(stringIDToTypeID("vertical"), 255.000000);
        list2.putObject(stringIDToTypeID("paint"), descriptor);
        descriptor.putDouble(stringIDToTypeID("horizontal"), 255.000000);
        descriptor.putDouble(stringIDToTypeID("vertical"), 255.000000);
        list2.putObject(stringIDToTypeID("paint"), descriptor);
        descriptor.putList(stringIDToTypeID("curve"), list2);
        list.putObject(stringIDToTypeID("curvesAdjustment"), descriptor);
        reference2.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("magenta"));
        descriptor.putReference(stringIDToTypeID("channel"), reference2);
        descriptor.putDouble(stringIDToTypeID("horizontal"), 0.000000);
        descriptor.putDouble(stringIDToTypeID("vertical"), 255.000000);
        list3.putObject(stringIDToTypeID("paint"), descriptor);
        descriptor.putDouble(stringIDToTypeID("horizontal"), 255.000000);
        descriptor.putDouble(stringIDToTypeID("vertical"), 255.000000);
        list3.putObject(stringIDToTypeID("paint"), descriptor);
        descriptor.putList(stringIDToTypeID("curve"), list3);
        list.putObject(stringIDToTypeID("curvesAdjustment"), descriptor);
        reference3.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("yellow"));
        descriptor.putReference(stringIDToTypeID("channel"), reference3);
        descriptor.putDouble(stringIDToTypeID("horizontal"), 0.000000);
        descriptor.putDouble(stringIDToTypeID("vertical"), 255.000000);
        list4.putObject(stringIDToTypeID("paint"), descriptor);
        descriptor.putDouble(stringIDToTypeID("horizontal"), 255.000000);
        descriptor.putDouble(stringIDToTypeID("vertical"), 255.000000);
        list4.putObject(stringIDToTypeID("paint"), descriptor);
        descriptor.putList(stringIDToTypeID("curve"), list4);
        list.putObject(stringIDToTypeID("curvesAdjustment"), descriptor);
        descriptor.putList(stringIDToTypeID("adjustment"), list);
        executeAction(stringIDToTypeID("curves"), descriptor, DialogModes.NO);

        app.displayDialogs = savedDisplayDialogs;

        alert("Ensure that the correct ICC profile is assigned to the document...");

        var idassignProfile = stringIDToTypeID("assignProfile");
        var desc313 = new ActionDescriptor();
        var idnull = stringIDToTypeID("null");
        var ref32 = new ActionReference();
        var iddocument = stringIDToTypeID("document");
        var idordinal = stringIDToTypeID("ordinal");
        var idtargetEnum = stringIDToTypeID("targetEnum");
        ref32.putEnumerated(iddocument, idordinal, idtargetEnum);
        desc313.putReference(idnull, ref32);
        executeAction(idassignProfile, desc313, DialogModes.ALL);

    } else {

        executeAction(stringIDToTypeID("revert"), undefined, DialogModes.NO);

        alert("The document isn't neutral, script cancelled!");

    }

} else {

    alert("The document isn't in Indexed Color Mode, script cancelled!");

}


function theHistProps(theHist) {
    /* Based on https://community.adobe.com/t5/photoshop/how-to-get-the-histogram-s-std-dev/td-p/9875041 */
    // get total number;
    var thePixels = 0;
    for (var m = 0; m < theHist.length; m++) {
        thePixels = thePixels + theHist[m];
    }
    // get mean and median
    var theMean = 0;
    var aTotal = 0;
    var check = false;
    for (var n = 0; n < theHist.length; n++) {
        theMean = theMean + (n * theHist[n] / thePixels);
        aTotal = aTotal + theHist[n];
        if (aTotal >= thePixels / 2 && check === false) {
            theMedian = n;
            check = true;
        }
    }
    // get standard deviation
    var theStandDev = 0;
    for (var o = 0; o < theHist.length; o++) {
        theStandDev = theStandDev + (Math.pow((o - theMean), 2) * theHist[o]);
    }
    theStandDev = Math.sqrt(theStandDev / thePixels);
    // Return the properties: theMean = [0] | theMedian = [1] | theStandDev = [2]
    return ([theMean, theMedian, theStandDev]);
}

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

LATEST

@timo35133572mgip 

 

Re-reading your original post, this may also be required to work with neutral RGB images in addition to neutral Indexed Color mode images? If this is the case, it's easy enough to modify the conditional check for the colour mode. Please confirm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines